added trainer

trainer is done, though there are some things to fix, which are commented.
All the rest of the errors are due to incomplete code which i cannot bring myself to complete at the moment.