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: Checks if the index contains a valid transition.
  
  Checks for collisions with the end of episodes and the current position
  of the cursor.
  
  Args:
    index: int, the index to the state in the transition.
  
  Returns:
    Is the index valid: Boolean.
docstr_tok: ["Checks","if","the","index","contains","a","valid","transition",".","Checks","for","collisions","with","the","end","of","episodes","and","the","current","position","of","the","cursor",".","Args",":","index",":","int",",","the","index","to","the","state","in","the","transition",".","Returns",":","Is","the","index","valid",":","Boolean","."]
code: def is_valid_transition(self, index):
      """Checks if the index contains a valid transition.
  
      Checks for collisions with the end of episodes and the current position
      of the cursor.
  
      Args:
        index: int, the index to the state in the transition.
  
      Returns:
        Is the index valid: Boolean.
  
      """
      # Check the index is in the valid range
      if index < 0 or index >= self._replay_capacity:
          return False
      if not self.is_full():
          # The indices and next_indices must be smaller than the cursor.
          if index >= self.cursor() - self._update_horizon:
              return False
          # The first few indices contain the padding states of the first episode.
          if index < self._stack_size - 1:
              return False
  
      # Skip transitions that straddle the cursor.
      if index in set(self.invalid_range):
          return False
  
      # If there are terminal flags in any other frame other than the last one
      # the stack is not valid, so don't sample it.
      if self.get_terminal_stack(index)[:-1].any():
          return False
  
      # If the episode ends before the update horizon, without a terminal signal,
      # it is invalid.
      for i in modulo_range(
          index, self._update_horizon, self._replay_capacity
      ):
          if (
              i in self.episode_end_indices
              and not self._store["terminal"][i]
          ):
              return False
  
      return True
  
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 19 for calling the OutOfGraphReplayBuffer obj's underlying member method code with example usage: obj.is_valid_transition(index) and returns: True, False, False, False, False, False, False