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: Load one snapshot of parameters from disk.
  
  Args:
      load_dir (str): Directory of the cloudpickle file
          to resume experiment from.
      itr (int or string): Iteration to load.
          Can be an integer, 'last' or 'first'.
  
  Returns:
      dict: Loaded snapshot.
  
  Raises:
      ValueError: If itr is neither an integer nor
          one of ("last", "first").
      FileNotFoundError: If the snapshot file is not found in load_dir.
      NotAFileError: If the snapshot exists but is not a file.
docstr_tok: ["Load","one","snapshot","of","parameters","from","disk",".","Args",":","load_dir","(","str",")",":","Directory","of","the","cloudpickle","file","to","resume","experiment","from",".","itr","(","int","or","string",")",":","Iteration","to","load",".","Can","be","an","integer",",","'last","'","or","'first","'",".","Returns",":","dict",":","Loaded","snapshot",".","Raises",":","ValueError",":","If","itr","is","neither","an","integer","nor","one","of","(","``","last","''",",","``","first","''",")",".","FileNotFoundError",":","If","the","snapshot","file","is","not","found","in","load_dir",".","NotAFileError",":","If","the","snapshot","exists","but","is","not","a","file","."]
code: def load(self, load_dir, itr="last"):
      # pylint: disable=no-self-use
      """Load one snapshot of parameters from disk.
  
      Args:
          load_dir (str): Directory of the cloudpickle file
              to resume experiment from.
          itr (int or string): Iteration to load.
              Can be an integer, 'last' or 'first'.
  
      Returns:
          dict: Loaded snapshot.
  
      Raises:
          ValueError: If itr is neither an integer nor
              one of ("last", "first").
          FileNotFoundError: If the snapshot file is not found in load_dir.
          NotAFileError: If the snapshot exists but is not a file.
  
      """
      if isinstance(itr, int) or itr.isdigit():
          load_from_file = os.path.join(
              load_dir, "itr_{}.pkl".format(itr)
          )
      else:
          if itr not in ("last", "first"):
              raise ValueError(
                  "itr should be an integer or 'last' or 'first'"
              )
  
          load_from_file = os.path.join(load_dir, "params.pkl")
          if not os.path.isfile(load_from_file):
              files = [
                  f for f in os.listdir(load_dir) if f.endswith(".pkl")
              ]
              if not files:
                  raise FileNotFoundError(
                      errno.ENOENT,
                      os.strerror(errno.ENOENT),
                      "*.pkl file in",
                      load_dir,
                  )
              files.sort(key=_extract_snapshot_itr)
              load_from_file = files[0] if itr == "first" else files[-1]
              load_from_file = os.path.join(load_dir, load_from_file)
  
      if not os.path.isfile(load_from_file):
          raise NotAFileError("File not existing: ", load_from_file)
  
      with open(load_from_file, "rb") as file:
          return cloudpickle.load(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 6 for calling the Snapshotter obj's underlying member method code with example usage: obj.load(load_dir, itr) and returns: cloudpickle