class_docstr: An episodic ReplayBuffer with Uniform sampling.
class_docstr_tok: ["An","episodic","ReplayBuffer","with","Uniform","sampling","."]
docstr: Creates a dataset that returns entries from the buffer in fixed order.
  
  Args:
    sample_batch_size: (Optional.) An optional batch_size to specify the
      number of items to return. See as_dataset() documentation. **NOTE** This
      argument may only be provided when `num_steps is not None`.  Otherwise
      the episodes may be different lengths and cannot be batched.
    num_steps: (Optional.)  Optional way to specify that sub-episodes are
      desired. See as_dataset() documentation.  Required if
      `sample_batch_size` is provided.
    sequence_preprocess_fn: (Optional.) Preprocessing function for sequences
      before they are sharded into subsequences of length `num_steps` and
      batched.
    num_parallel_calls: (Optional.) Number elements to process in parallel.
      See as_dataset() documentation.  Note, that the parallelism here is not
      "sloppy", in that setting this value does not affect the order in which
      frames are returned.
  
  Returns:
    A dataset of type tf.data.Dataset, elements of which are 2-tuples of:
  
      - An item or sequence of items or batch thereof
      - Auxiliary info for the items (i.e. ids, probs).
  
  Raises:
    ValueError: If `sample_batch_size is not None` but `num_steps is None`.
      When `num_steps is None`, the episodes returned may have different
      lengths, and there is no unique way to batch them.
    NotImplementedError: If `sequence_preprocess_fn != None` is passed in.
code: def _single_deterministic_pass_dataset(
      self,
      sample_batch_size=None,
      num_steps=None,
      sequence_preprocess_fn=None,
      num_parallel_calls=tf.data.experimental.AUTOTUNE,
  ):
      """Creates a dataset that returns entries from the buffer in fixed order.
  
      Args:
        sample_batch_size: (Optional.) An optional batch_size to specify the
          number of items to return. See as_dataset() documentation. **NOTE** This
          argument may only be provided when `num_steps is not None`.  Otherwise
          the episodes may be different lengths and cannot be batched.
        num_steps: (Optional.)  Optional way to specify that sub-episodes are
          desired. See as_dataset() documentation.  Required if
          `sample_batch_size` is provided.
        sequence_preprocess_fn: (Optional.) Preprocessing function for sequences
          before they are sharded into subsequences of length `num_steps` and
          batched.
        num_parallel_calls: (Optional.) Number elements to process in parallel.
          See as_dataset() documentation.  Note, that the parallelism here is not
          "sloppy", in that setting this value does not affect the order in which
          frames are returned.
  
      Returns:
        A dataset of type tf.data.Dataset, elements of which are 2-tuples of:
  
          - An item or sequence of items or batch thereof
          - Auxiliary info for the items (i.e. ids, probs).
  
      Raises:
        ValueError: If `sample_batch_size is not None` but `num_steps is None`.
          When `num_steps is None`, the episodes returned may have different
          lengths, and there is no unique way to batch them.
        NotImplementedError: If `sequence_preprocess_fn != None` is passed in.
      """
      if sequence_preprocess_fn is not None:
          raise NotImplementedError(
              "sequence_preprocess_fn is not supported."
          )
      if sample_batch_size is not None and num_steps is None:
          raise ValueError(
              "When requesting a batched dataset from EpisodicReplayBuffer, "
              "num_steps must be provided (but saw num_steps=None)."
          )
  
      drop_remainder = self._dataset_drop_remainder
      window_shift = self._dataset_window_shift
  
      def get_episode_ids(_):
          min_frame_offset, max_frame_offset = _valid_range_ids(
              self._get_last_episode_id(), self._capacity
          )
          return tf.data.Dataset.range(
              min_frame_offset, max_frame_offset
          )
  
      # Instead of calling get_episode_ids and creating a dataset from this,
      # we instead build a dataset whose iterator recalculates the available
      # episode_ids in the dataset whenever it is reinitialized.  We
      # want to do this because the RB valid episodes can change over time;
      # specifically the RB may be empty when this dataset is first created.
      episode_ids_ds = tf.data.Dataset.range(1).flat_map(
          get_episode_ids
      )
  
      def read_episode(episode_id):
          row = self._get_episode_id_location(episode_id)
          return self._data_table.get_episode_values(row)
  
      ds = episode_ids_ds.map(
          read_episode, num_parallel_calls=num_parallel_calls
      )
      if sample_batch_size is None:
          if num_steps is not None:
              # Disable autograph to make debugging errors easier.
              @tf.autograph.experimental.do_not_convert
              def group_windows(windowed):
                  return tf.data.Dataset.zip(
                      tf.nest.map_structure(
                          lambda d: d.batch(
                              num_steps, drop_remainder=drop_remainder
                          ),
                          windowed,
                      )
                  )
  
              ds = (
                  ds.unbatch()
                  .window(num_steps, shift=window_shift)
                  .flat_map(group_windows)
              )
      else:
          # sample_batch_size is not None, which also implies num_steps is not None
          # per the check at the top of this function.
          assert num_steps is not None
  
          # Split up the replay buffer into sample_batch_size parallel datasets.
          ds_shards = tf.data.Dataset.range(sample_batch_size).map(
              lambda i: ds.shard(sample_batch_size, i)
          )
  
          # In each dataset, convert different-length episodes to blocks of size
          # num_steps.  The very final blocks may be dropped if their size is not a
          # multiple of num_steps.
          # Disable autograph to make debugging errors easier.
          @tf.autograph.experimental.do_not_convert
          def rebatch(ds_):
              def batch_nest(window):
                  return tf.data.Dataset.zip(
                      tf.nest.map_structure(
                          lambda d: d.batch(
                              num_steps, drop_remainder=True
                          ),
                          window,
                      )
                  )
  
              return (
                  ds_.unbatch()
                  .window(num_steps, shift=window_shift)
                  .flat_map(batch_nest)
              )
  
          ds_shards = ds_shards.map(rebatch)
          ds = ds_shards.interleave(lambda ds_: ds_)
          # Batch by sample_batch_size from the interleaved stream.
          ds = ds.batch(
              sample_batch_size, drop_remainder=drop_remainder
          )
  
      return ds
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import gin
  import tensorflow
  from tf_agents import specs
  from tf_agents.replay_buffers import episodic_table
  from tf_agents.replay_buffers import replay_buffer
  from tf_agents.replay_buffers import table
  from tf_agents.utils import common
  from tensorflow.python.data.util import nest
  from tensorflow.python.layers import utils
  from tensorflow.python.ops import list_ops
  from tensorflow.python.ops.distributions import util
label_desc: Use image node_id 12 for calling the EpisodicReplayBuffer obj's underlying member method code with example usage: obj._single_deterministic_pass_dataset(sample_batch_size, num_steps, sequence_preprocess_fn, num_parallel_calls) and returns: ds, tf, self, ds_, tf, tf