class_docstr: Separately save the model with minimum value of some statistics.
class_docstr_tok: ["Separately","save","the","model","with","minimum","value","of","some","statistics","."]
code: def _save(self):
      ckpt = tf.train.get_checkpoint_state(self.checkpoint_dir)
      if ckpt is None:
          raise RuntimeError(
              "[MinSaver] Cannot find a checkpoint state. Do you forget to use ModelSaver?"
          )
      path = ckpt.model_checkpoint_path
  
      extreme_name = "maximum" if self.reverse else "minimum"
      if not path.endswith(str(self.best[0])):
          logger.warn(
              "[MinSaver] New {} '{}' found at global_step={}, but the latest checkpoint is {}.".format(
                  extreme_name, self.monitor_stat, self.best[0], path
              )
          )
          logger.warn(
              "MinSaver will do nothing this time. "
              "The callbacks may have inconsistent frequency or wrong order."
          )
          return
  
      newname = os.path.join(
          self.checkpoint_dir,
          self.filename
          or (
              "max-" + self.monitor_stat
              if self.reverse
              else "min-" + self.monitor_stat
          ),
      )
      files_to_copy = tf.gfile.Glob(path + "*")
      for file_to_copy in files_to_copy:
          tf.gfile.Copy(
              file_to_copy,
              file_to_copy.replace(path, newname),
              overwrite=True,
          )
      logger.info(
          "Model at global_step={} with {} {}={:.5g} saved.".format(
              self.best[0],
              extreme_name,
              self.monitor_stat,
              self.best[1],
          )
      )
  
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 4 for calling the MinSaver obj's underlying member method code with example usage: obj._save() without return types