class_docstr: Base class for a trainer.
      
docstr: Register callbacks to the trainer.
  It can only be called before :meth:`Trainer.train()`.
  
  Args:
      cb (Callback or [Callback]): a callback or a list of callbacks
  
  Returns:
      succeed or not
docstr_tok: ["Register","callbacks","to","the","trainer",".","It","can","only","be","called","before",":","meth",":","`","Trainer.train","(",")","`",".","Args",":","cb","(","Callback","or","[","Callback","]",")",":","a","callback","or","a","list","of","callbacks","Returns",":","succeed","or","not"]
code: def _register_callback(self, cb):
      """
      Register callbacks to the trainer.
      It can only be called before :meth:`Trainer.train()`.
  
      Args:
          cb (Callback or [Callback]): a callback or a list of callbacks
  
      Returns:
          succeed or not
      """
      if isinstance(cb, (list, tuple)):
          for x in cb:
              self._register_callback(x)
          return
      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))
          )
          return False
      else:
          self._callbacks.append(cb)
          return True
  
imports: import copy
  import time
  import weakref
  import tensorflow
  from ..compat import tfv1
  from ..callbacks import Callback, Callbacks, Monitors, MonitorBase
  from ..callbacks.steps import MaintainStepCounter
  from ..tfutils import get_global_step_value
  from ..tfutils.model_utils import describe_trainable_vars
  from ..tfutils.sesscreate import NewSessionCreator, ReuseSessionCreator
  from ..tfutils.sessinit import JustCurrentSession, SessionInit
  from ..utils import logger
  from ..utils.argtools import call_only_once
  from ..utils.utils import humanize_time_delta
  from .config import DEFAULT_CALLBACKS, DEFAULT_MONITORS, TrainConfig
label_desc: Use image node_id 2 for calling the Trainer obj's underlying member method code with example usage: obj._register_callback(cb) and returns: False, True