class_docstr: Base class for a trainer.
      
docstr: Setup callbacks and monitors. Must be called after the main graph is built.
  
  Args:
      callbacks ([Callback]):
      monitors ([MonitorBase]):
docstr_tok: ["Setup","callbacks","and","monitors",".","Must","be","called","after","the","main","graph","is","built",".","Args",":","callbacks","(","[","Callback","]",")",":","monitors","(","[","MonitorBase","]",")",":"]
code: def setup_callbacks(self, callbacks, monitors):
      """
      Setup callbacks and monitors. Must be called after the main graph is built.
  
      Args:
          callbacks ([Callback]):
          monitors ([MonitorBase]):
      """
      assert isinstance(callbacks, list), callbacks
      assert isinstance(monitors, list), monitors
      describe_trainable_vars()  # TODO weird
  
      self.register_callback(MaintainStepCounter())
      for cb in callbacks:
          self.register_callback(cb)
      for cb in self._callbacks:
          assert not isinstance(
              cb, MonitorBase
          ), "Monitor cannot be pre-registered for now!"
      registered_monitors = []
      for m in monitors:
          if self.register_callback(m):
              registered_monitors.append(m)
      self.monitors = Monitors(registered_monitors)
      self.register_callback(
          self.monitors
      )  # monitors is also a callback
  
      # some final operations that might modify the graph
      logger.info("Setup callbacks graph ...")
      self._callbacks = Callbacks(self._callbacks)
      self._callbacks.setup_graph(weakref.proxy(self))
  
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 4 for calling the Trainer obj's underlying member method code with example usage: obj.setup_callbacks(callbacks, monitors) without return types