class_docstr: This class handles iteration events to save the model as checkpoint files.
class_docstr_tok: ["This","class","handles","iteration","events","to","save","the","model","as","checkpoint","files","."]
code: def __init__(
      self,
      model_dir,
      save_every_n=0,
      max_checkpoints=1,
      is_training_action=True,
      **_unused,
  ):
      self.save_every_n = save_every_n
      self.max_checkpoints = max_checkpoints
      self.file_name_prefix = make_model_name(model_dir)
      self.saver = None
  
      # initialise the saver after the graph finalised
      SESS_STARTED.connect(self.init_saver)
      # save the training model at a positive frequency
      if self.save_every_n > 0:
          ITER_FINISHED.connect(self.save_model_interval)
      # always save the final training model before exiting
      if is_training_action:
          SESS_FINISHED.connect(self.save_model)
  
file_path: NiftyNet/niftynet/engine/handler_model.py
imports: import os
  import tensorflow
  from niftynet.engine.application_variables import global_vars_init_or_restore
  from niftynet.engine.signal import ITER_FINISHED, SESS_FINISHED, SESS_STARTED
  from niftynet.io.misc_io import touch_folder
label_desc: Use image node_id 1 to create a new ModelSaver object from inherited base classes: object with example: obj = ModelSaver(model_dir, save_every_n, max_checkpoints, is_training_action)