class_docstr: An episodic ReplayBuffer with Uniform sampling.
class_docstr_tok: ["An","episodic","ReplayBuffer","with","Uniform","sampling","."]
docstr: Adds a sequence of items to the replay buffer for the selected episode.
  
  Args:
    items: A sequence of items to be added to the buffer. Items will have the
      same structure as the data_spec of this class, but the tensors in items
      will have an outer sequence dimension in addition to the corresponding
      spec in data_spec.
    episode_id: A Tensor containing the current episode_id.
  
  Returns:
    An updated episode id Tensor.  Accessing this episode id value will,
    as a side effect, start or end the current episode in the buffer.
code: def add_sequence(self, items, episode_id):
      """Adds a sequence of items to the replay buffer for the selected episode.
  
      Args:
        items: A sequence of items to be added to the buffer. Items will have the
          same structure as the data_spec of this class, but the tensors in items
          will have an outer sequence dimension in addition to the corresponding
          spec in data_spec.
        episode_id: A Tensor containing the current episode_id.
  
      Returns:
        An updated episode id Tensor.  Accessing this episode id value will,
        as a side effect, start or end the current episode in the buffer.
      """
      episode_id.shape.assert_has_rank(0)
      with tf.device(self._device):
          with tf.name_scope("add_steps"):
              # If users pass in, e.g., a python list [2, 3, 4] of type int32
              # but the data_spec requires an int64, then the user will get a very
              # confusing error much deeper in the TensorList code.  Doing the
              # conversion here either converts when necessary, or raises an error
              # on incompatible types earlier in the run.
              items = tf.nest.map_structure(
                  lambda x, spec: tf.convert_to_tensor(
                      value=x, dtype=spec.dtype
                  ),
                  items,
                  self._data_spec,
              )
              item_0 = tf.nest.flatten(items)[0]
              num_steps = tf.cast(
                  tf.compat.dimension_value(item_0.shape[0])
                  or tf.shape(input=item_0)[0],
                  tf.int64,
              )
              # If begin_episode is True, then the increment of the episode_id happens
              # before trying to add anything to the buffer, regardless of whether the
              # item will actually be added.
              begin_episode = self._begin_episode_fn(items)
              end_episode = self._end_episode_fn(items)
              new_episode_id = self._get_episode_id(
                  episode_id, begin_episode, end_episode
              )
              episode_location = self._get_episode_id_location(
                  new_episode_id
              )
  
              def _add_steps():
                  """Add sequence of items to the buffer."""
                  inc_episode_length = (
                      self._increment_episode_length_locked(
                          episode_location, num_steps
                      )
                  )
                  write_data_op = self._data_table.append(
                      episode_location, items
                  )
                  with tf.control_dependencies(
                      [inc_episode_length, write_data_op]
                  ):
                      return tf.identity(new_episode_id)
  
              # Accessing episode_id may modify
              # self._episodes_loc_to_id_map, so ensure it is executed
              # before the tf.equal.
              with tf.control_dependencies([new_episode_id]):
                  episode_valid = tf.equal(
                      self._episodes_loc_to_id_map[episode_location],
                      new_episode_id,
                  )
  
              def _maybe_add_steps():
                  return self._add_episode_critical_section.execute(
                      _add_steps
                  )
  
              return utils.smart_cond(
                  episode_valid,
                  _maybe_add_steps,
                  lambda: tf.identity(new_episode_id),
                  name="conditioned_add_steps",
              )
  
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 6 for calling the EpisodicReplayBuffer obj's underlying member method code with example usage: obj.add_sequence(items, episode_id) and returns: utils, self, tf