class_docstr: Snapshotter snapshots training data.
  
  When training, it saves data to binary files. When resuming,
  it loads from saved data.
  
  Args:
      snapshot_dir (str): Path to save the log and iteration snapshot.
      snapshot_mode (str): Mode to save the snapshot. Can be either "all"
          (all iterations will be saved), "last" (only the last iteration
          will be saved), "gap" (every snapshot_gap iterations are saved),
          "gap_and_last" (save the last iteration as 'params.pkl' and save
          every snapshot_gap iteration separately), "gap_overwrite" (same as
          gap but overwrites the last saved snapshot), or "none" (do not
          save snapshots).
      snapshot_gap (int): Gap between snapshot iterations. Wait this number
          of iterations before taking another snapshot.
class_docstr_tok: ["Snapshotter","snapshots","training","data",".","When","training",",","it","saves","data","to","binary","files",".","When","resuming",",","it","loads","from","saved","data",".","Args",":","snapshot_dir","(","str",")",":","Path","to","save","the","log","and","iteration","snapshot",".","snapshot_mode","(","str",")",":","Mode","to","save","the","snapshot",".","Can","be","either","``","all","''","(","all","iterations","will","be","saved",")",",","``","last","''","(","only","the","last","iteration","will","be","saved",")",",","``","gap","''","(","every","snapshot_gap","iterations","are","saved",")",",","``","gap_and_last","''","(","save","the","last","iteration","as","'params.pkl","'","and","save","every","snapshot_gap","iteration","separately",")",",","``","gap_overwrite","''","(","same","as","gap","but","overwrites","the","last","saved","snapshot",")",",","or","``","none","''","(","do","not","save","snapshots",")",".","snapshot_gap","(","int",")",":","Gap","between","snapshot","iterations",".","Wait","this","number","of","iterations","before","taking","another","snapshot","."]
docstr: Save the parameters if at the right iteration.
  
  Args:
      itr (int): Number of iterations. Used as the index of snapshot.
      params (obj): Content of snapshot to be saved.
  
  Raises:
      ValueError: If snapshot_mode is not one of "all", "last", "gap",
          "gap_overwrite", "gap_and_last", or "none".
docstr_tok: ["Save","the","parameters","if","at","the","right","iteration",".","Args",":","itr","(","int",")",":","Number","of","iterations",".","Used","as","the","index","of","snapshot",".","params","(","obj",")",":","Content","of","snapshot","to","be","saved",".","Raises",":","ValueError",":","If","snapshot_mode","is","not","one","of","``","all","''",",","``","last","''",",","``","gap","''",",","``","gap_overwrite","''",",","``","gap_and_last","''",",","or","``","none","''","."]
code: def save_itr_params(self, itr, params):
      """Save the parameters if at the right iteration.
  
      Args:
          itr (int): Number of iterations. Used as the index of snapshot.
          params (obj): Content of snapshot to be saved.
  
      Raises:
          ValueError: If snapshot_mode is not one of "all", "last", "gap",
              "gap_overwrite", "gap_and_last", or "none".
  
      """
      file_name = None
  
      if self._snapshot_mode == "all":
          file_name = os.path.join(
              self._snapshot_dir, "itr_%d.pkl" % itr
          )
      elif self._snapshot_mode == "gap_overwrite":
          if itr % self._snapshot_gap == 0:
              file_name = os.path.join(self._snapshot_dir, "params.pkl")
      elif self._snapshot_mode == "last":
          # override previous params
          file_name = os.path.join(self._snapshot_dir, "params.pkl")
      elif self._snapshot_mode == "gap":
          if itr % self._snapshot_gap == 0:
              file_name = os.path.join(
                  self._snapshot_dir, "itr_%d.pkl" % itr
              )
      elif self._snapshot_mode == "gap_and_last":
          if itr % self._snapshot_gap == 0:
              file_name = os.path.join(
                  self._snapshot_dir, "itr_%d.pkl" % itr
              )
          file_name_last = os.path.join(
              self._snapshot_dir, "params.pkl"
          )
          with open(file_name_last, "wb") as file:
              cloudpickle.dump(params, file)
      elif self._snapshot_mode == "none":
          pass
      else:
          raise ValueError(
              "Invalid snapshot mode {}".format(self._snapshot_mode)
          )
  
      if file_name:
          with open(file_name, "wb") as file:
              cloudpickle.dump(params, file)
  
file_path: garage/src/garage/experiment/snapshotter.py
imports: import collections
  import errno
  import os
  import pathlib
  import cloudpickle
label_desc: Use image node_id 5 for calling the Snapshotter obj's underlying member method code with example usage: obj.save_itr_params(itr, params) without return types