class_docstr: Save the model once triggered.
class_docstr_tok: ["Save","the","model","once","triggered","."]
code: def _setup_graph(self):
      assert (
          self.checkpoint_dir is not None
      ), "Please provide 'checkpoint_dir' for ModelSaver, or use logger.set_logger_dir()"
      vars = []
      for key in self.var_collections:
          vars.extend(tf.get_collection(key))
      vars = list(set(vars))
      self.path = os.path.join(self.checkpoint_dir, "model")
      self.saver = tf.train.Saver(
          var_list=vars,
          max_to_keep=self._max_to_keep,
          keep_checkpoint_every_n_hours=self._keep_every_n_hours,
          write_version=tf.train.SaverDef.V2,
          save_relative_paths=True,
      )
      # Scaffold will call saver.build from this collection
      tf.add_to_collection(tf.GraphKeys.SAVERS, self.saver)
  
file_path: tensorpack/tensorpack/callbacks/saver.py
imports: import os
  from datetime import datetime
  from ..compat import tfv1
  from ..utils import fs, logger
  from .base import Callback
label_desc: Use image node_id 2 for calling the ModelSaver obj's underlying member method code with example usage: obj._setup_graph() without return types