'Register a callback to the trainer.
It can only be called before :meth:`Trainer.train` gets called.'

def register_callback(self, cb):

    assert isinstance(cb, Callback), cb
    assert (not isinstance(self._callbacks, Callbacks)), 'Cannot    register    more    callbacks    after    trainer    was    setup!'
    if ((not self.is_chief) and cb.chief_only):
        logger.warn('Callback    {}    is    chief-only,    skipped.'.format(str(cb)))
    else:
        self._callbacks.append(cb)
