Start tightening up trainer code.
Start tightening up trainer code.

This step: highlight top-level logic in trainer.py's main, by moving next-level
details into smallish supporting functions.

PiperOrigin-RevId: 286218424

google/trax,google/trax