class_docstr: A simple out-of-graph Replay Buffer.
  
  Stores transitions, state, action, reward, next_state, terminal (and any
  extra contents specified) in a circular buffer and provides a uniform
  transition sampling function.
  
  When the states consist of stacks of observations storing the states is
  inefficient. This class writes observations and constructs the stacked states
  at sample time.
  
  Attributes:
    add_count: int, counter of how many transitions have been added (including
      the blank ones at the beginning of an episode).
    invalid_range: np.array, an array with the indices of cursor-related invalid
      transitions
    episode_end_indices: set[int], a set of indices corresponding to the
      end of an episode.
docstr: Save the OutOfGraphReplayBuffer attributes into a file.
  
  This method will save all the replay buffer's state in a single file.
  
  Args:
    checkpoint_dir: str, the directory where numpy checkpoint files should be
      saved.
    iteration_number: int, iteration_number to use as a suffix in naming
      numpy checkpoint files.
docstr_tok: ["Save","the","OutOfGraphReplayBuffer","attributes","into","a","file",".","This","method","will","save","all","the","replay","buffer","'s","state","in","a","single","file",".","Args",":","checkpoint_dir",":","str",",","the","directory","where","numpy","checkpoint","files","should","be","saved",".","iteration_number",":","int",",","iteration_number","to","use","as","a","suffix","in","naming","numpy","checkpoint","files","."]
code: def save(self, checkpoint_dir, iteration_number):
      """Save the OutOfGraphReplayBuffer attributes into a file.
  
      This method will save all the replay buffer's state in a single file.
  
      Args:
        checkpoint_dir: str, the directory where numpy checkpoint files should be
          saved.
        iteration_number: int, iteration_number to use as a suffix in naming
          numpy checkpoint files.
      """
      if not tf.io.gfile.exists(checkpoint_dir):
          return
  
      checkpointable_elements = self._return_checkpointable_elements()
  
      for attr in checkpointable_elements:
          filename = self._generate_filename(
              checkpoint_dir, attr, iteration_number
          )
          with tf.io.gfile.GFile(filename, "wb") as f:
              with gzip.GzipFile(fileobj=f, mode="wb") as outfile:
                  # Checkpoint the np arrays in self._store with np.save instead of
                  # pickling the dictionary is critical for file size and performance.
                  # STORE_FILENAME_PREFIX indicates that the variable is contained in
                  # self._store.
                  if attr.startswith(STORE_FILENAME_PREFIX):
                      array_name = attr[len(STORE_FILENAME_PREFIX) :]
                      np.save(
                          outfile,
                          self._store[array_name],
                          allow_pickle=False,
                      )
                  # Some numpy arrays might not be part of storage
                  elif isinstance(self.__dict__[attr], np.ndarray):
                      np.save(
                          outfile,
                          self.__dict__[attr],
                          allow_pickle=False,
                      )
                  else:
                      pickle.dump(self.__dict__[attr], outfile)
  
          # After writing a checkpoint file, we garbage collect the checkpoint file
          # that is four versions old.
          stale_iteration_number = (
              iteration_number - self._checkpoint_duration
          )
  
          # If keep_every has been set, we spare every keep_every'th checkpoint.
          if self._keep_every is not None and (
              stale_iteration_number % self._keep_every == 0
          ):
              return
  
          if stale_iteration_number >= 0:
              stale_filename = self._generate_filename(
                  checkpoint_dir, attr, stale_iteration_number
              )
              try:
                  tf.io.gfile.remove(stale_filename)
              except tf.errors.NotFoundError:
                  pass
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import gzip
  import math
  import os
  import pickle
  from absl import logging
  import gin.tf
  import numpy
  import tensorflow
label_desc: Use image node_id 26 for calling the OutOfGraphReplayBuffer obj's underlying member method code with example usage: obj.save(checkpoint_dir, iteration_number) without return types