class_docstr: Implement the runtime logic for jobs with checkpointing at the level of
  epoch. Can be used to run either single-host or distributed jobs. Job
  runner is a callable to be called once from the master, passing a session
  as an argument. This call will block until the Job execution is complete.
  
  If a checkpoint_manager is passed, checkpoints will be taken after
  initialization and after each epoch execution. If, in addition,
  `resume_from_epoch` is an epoch number, the corresponding checkpoint will
  be loaded and job execution will continue from the given epoch. In
  this case, the job's init_group will not be run.
  
  Refer to checkpoint_test.py for an example.
class_docstr_tok: ["Implement","the","runtime","logic","for","jobs","with","checkpointing","at","the","level","of","epoch",".","Can","be","used","to","run","either","single-host","or","distributed","jobs",".","Job","runner","is","a","callable","to","be","called","once","from","the","master",",","passing","a","session","as","an","argument",".","This","call","will","block","until","the","Job","execution","is","complete",".","If","a","checkpoint_manager","is","passed",",","checkpoints","will","be","taken","after","initialization","and","after","each","epoch","execution",".","If",",","in","addition",",","`","resume_from_epoch","`","is","an","epoch","number",",","the","corresponding","checkpoint","will","be","loaded","and","job","execution","will","continue","from","the","given","epoch",".","In","this","case",",","the","job","'s","init_group","will","not","be","run",".","Refer","to","checkpoint_test.py","for","an","example","."]
docstr: Triggers operation to save checkpoints
  
  This method will trigger the Save ops to serialize and persist the
  blobs present in the global workspaace.
  
  Args:
      epoch: An integer. The checkpoint epoch-id that we are saving.
      session: A Session object to execute the save ops.
  
  Raises:
      ValueError: When the checkpoint manager is invalid.
docstr_tok: ["Triggers","operation","to","save","checkpoints","This","method","will","trigger","the","Save","ops","to","serialize","and","persist","the","blobs","present","in","the","global","workspaace",".","Args",":","epoch",":","An","integer",".","The","checkpoint","epoch-id","that","we","are","saving",".","session",":","A","Session","object","to","execute","the","save","ops",".","Raises",":","ValueError",":","When","the","checkpoint","manager","is","invalid","."]
code: def save_checkpoints(self, epoch, session):
      """Triggers operation to save checkpoints
  
      This method will trigger the Save ops to serialize and persist the
      blobs present in the global workspaace.
  
      Args:
          epoch: An integer. The checkpoint epoch-id that we are saving.
          session: A Session object to execute the save ops.
  
      Raises:
          ValueError: When the checkpoint manager is invalid.
      """
      if not self.checkpoint_manager:
          raise ValueError("Checkpoint manager is None")
      try:
          is_accessible = self.checkpoint_manager.cp_accessible(
              epoch=None
          )
          if is_accessible:
              logger.info(
                  "Saving checkpoints for epoch {}".format(epoch)
              )
              session.run(self.checkpoint_manager.save(epoch))
              self.checkpoint_manager.write_checkpoint_metadata(epoch)
              logger.info("Checkpoints saved")
              self.checkpoint_manager.report_checkpoint_stats(
                  "checkpoint_save"
              )
          else:
              logger.warning("Checkpoint files cannot be accessed!")
      except Exception as ex:
          logger.warning(
              "Unable to write checkpoint for epoch {}. Error={}".format(
                  epoch, ex
              )
          )
  
imports: import os
  import logging
  from caffe2.python import core, context
  from caffe2.python.net_builder import ops
  from caffe2.python.task import final_output, Node, Task, TaskGroup, TaskOutput, WorkspaceType
label_desc: Use image node_id 4 for calling the JobRunner obj's underlying member method code with example usage: obj.save_checkpoints(epoch, session) without return types