class_docstr: Observer for writing episodes to Reverb.
  
  This observer should be called at every step. It does not support batched
  trajectories. The steps are cached and written at the end of the episode.
  
  At the end of each episode, an item is written to Reverb. Each item is the
  trajectory containing an episode, including a boundary step in the end.
  Therefore, the sequence lengths of the items may vary. If you want a fixed
  sequence length, use `ReverbAddTrajectoryObserver` instead.
  
  Unfinished episodes remain in the cache and do not get written until
  `reset(write_cached_steps=True)` is called.
  
  TODO(b/176261664): Note that this observer only supports batch_size=1 from the
  consumer, if your episodes have variable lengths.
docstr: Creates an instance of the ReverbAddEpisodeObserver.
  
  **Note**: This observer is designed to work with py_drivers only, and does
  not support batches.
  
  TODO(b/158865335): Optionally truncate long episodes and add to buffer.
  
  Args:
    py_client: Python client for the reverb replay server.
    table_name: The table name(s) where samples will be written to.
    max_sequence_length: An integer. `max_sequence_length` used to write to
      the replay buffer tables. This defines the size of the internal buffer
      controlling the `upper` limit of the number of timesteps which can be
      referenced in a single prioritized item. Note that this is the maximum
      number of trajectories across all the cached episodes that you are
      writing into the replay buffer (e.g. `number_of_episodes`).
      `max_sequence_length` is not a limit of how many timesteps or items that
      can be inserted into the replay buffer. Note that, since
      `max_sequence_length` controls the size of internal buffer, it is
      suggested not to set this value to a very large number. If the number of
      steps in an episode is more than `max_sequence_length`, only items up to
      `max_sequence_length` is written into the table.
    priority: Initial priority for the table.
    bypass_partial_episodes: If `False` (default) and an episode length is
      greater than `max_sequence_length`, a `ValueError` is raised. If set to
      `True`, the episodes with length more than `max_sequence_length` do not
      cause a `ValueError`. These episodes are bypassed (will NOT be written
      into the replay buffer) and an error message is shown to the user. Note
      that in this case (`bypass_partial_episodes=True`), the steps for
      episodes with length more than `max_sequence_length` are wasted and
      thrown away. This decision is made to guarantee that the replay buffer
      always has FULL episodes. Note that, `max_sequence_length` is just an
      upper bound.
  
  Raises:
    ValueError: If `priority` is not numeric.
    ValueError: If max_sequence_length is not positive.
code: def __init__(
      self,
      py_client: types.ReverbClient,
      table_name: Union[Text, Sequence[Text]],
      max_sequence_length: int,
      priority: Union[float, int] = 1,
      bypass_partial_episodes: bool = False,
  ):
      """Creates an instance of the ReverbAddEpisodeObserver.
  
      **Note**: This observer is designed to work with py_drivers only, and does
      not support batches.
  
      TODO(b/158865335): Optionally truncate long episodes and add to buffer.
  
      Args:
        py_client: Python client for the reverb replay server.
        table_name: The table name(s) where samples will be written to.
        max_sequence_length: An integer. `max_sequence_length` used to write to
          the replay buffer tables. This defines the size of the internal buffer
          controlling the `upper` limit of the number of timesteps which can be
          referenced in a single prioritized item. Note that this is the maximum
          number of trajectories across all the cached episodes that you are
          writing into the replay buffer (e.g. `number_of_episodes`).
          `max_sequence_length` is not a limit of how many timesteps or items that
          can be inserted into the replay buffer. Note that, since
          `max_sequence_length` controls the size of internal buffer, it is
          suggested not to set this value to a very large number. If the number of
          steps in an episode is more than `max_sequence_length`, only items up to
          `max_sequence_length` is written into the table.
        priority: Initial priority for the table.
        bypass_partial_episodes: If `False` (default) and an episode length is
          greater than `max_sequence_length`, a `ValueError` is raised. If set to
          `True`, the episodes with length more than `max_sequence_length` do not
          cause a `ValueError`. These episodes are bypassed (will NOT be written
          into the replay buffer) and an error message is shown to the user. Note
          that in this case (`bypass_partial_episodes=True`), the steps for
          episodes with length more than `max_sequence_length` are wasted and
          thrown away. This decision is made to guarantee that the replay buffer
          always has FULL episodes. Note that, `max_sequence_length` is just an
          upper bound.
  
      Raises:
        ValueError: If `priority` is not numeric.
        ValueError: If max_sequence_length is not positive.
      """
      if max_sequence_length <= 0:
          raise ValueError(
              "`max_sequence_length` must be an integer greater equal one."
          )
  
      if isinstance(table_name, Text):
          self._table_names = [table_name]
      else:
          self._table_names = table_name
  
      self._max_sequence_length = max_sequence_length
      self._priority = priority
  
      self._py_client = py_client
      self._writer = self._py_client.trajectory_writer(
          num_keep_alive_refs=self._max_sequence_length + 1,
          validate_items=False,
      )
      self._cached_steps = 0
      self._bypass_partial_episodes = bypass_partial_episodes
      self._overflow_episode = False
      self._writer_has_data = False
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Sequence, Text, Union
  from absl import logging
  import tensorflow
  from tf_agents.trajectories import trajectory
  from tf_agents.typing import types
  from tf_agents.utils import lazy_loader
label_desc: Use image node_id 1 to create a new ReverbAddEpisodeObserver object from inherited base classes: object with example: obj = ReverbAddEpisodeObserver(py_client, table_name, max_sequence_length, priority, bypass_partial_episodes)