class_docstr: Stateful observer for writing fixed length trajectories to Reverb.
  
  This observer should be called at every environment step. It does not support
  batched trajectories.
  
  Steps are cached until `sequence_length` steps are gathered. At which point an
  item is created. From there on a new item is created every `stride_length`
  observer calls.
  
  If an episode terminates before enough steps are cached, the data is discarded
  unless `pad_end_of_episodes` is set.
docstr: Creates an instance of the ReverbAddTrajectoryObserver.
  
  If multiple table_names and sequence lengths are provided data will only be
  stored once but be available for sampling with multiple sequence lengths
  from the respective reverb tables.
  
  **Note**: This observer is designed to work with py_drivers only, and does
  not support batches.
  
  Args:
    py_client: Python client for the reverb replay server.
    table_name: The table name(s) where samples will be written to.
    sequence_length: The sequence_length used to write to the given table.
    stride_length: The integer stride for the sliding window for overlapping
      sequences.  The default value of `1` creates an item for every window.
      Using `L = sequence_length` this means items are created for times `{0,
      1, .., L-1}, {1, 2, .., L}, ...`.  In contrast, `stride_length = L` will
      create an item only for disjoint windows `{0, 1, ..., L-1}, {L, ..., 2 *
      L - 1}, ...`.
    priority: Initial priority for new samples in the RB.
    pad_end_of_episodes: At the end of an episode, the cache is dropped by
      default. When `pad_end_of_episodes = True`, the cache gets padded with
      boundary steps (last->first) with `0` values everywhere and padded items
      of `sequence_length` are written to Reverb.
    tile_end_of_episodes: If `pad_end_of_episodes` is True then, the last
      padded item starts with a boundary step from the episode.  When this
      option is True the following items will be generated:  F, M, L, P M, L,
      P, P L, P, P, P  If False, only a single one will be generated:  F, M,
      L, P  For training recurrent models on environments where required
      information is only available at the start of the episode it is useful
      to set `tile_end_of_episodes=False` and the `sequence_length` to be the
      length of the longest episode.
  
  Raises:
    ValueError: If `tile_end_of_episodes` is set without
      `pad_end_of_episodes`.
code: def __init__(
      self,
      py_client: types.ReverbClient,
      table_name: Union[Text, Sequence[Text]],
      sequence_length: int,
      stride_length: int = 1,
      priority: Union[float, int] = 1,
      pad_end_of_episodes: bool = False,
      tile_end_of_episodes: bool = False,
  ):
      """Creates an instance of the ReverbAddTrajectoryObserver.
  
      If multiple table_names and sequence lengths are provided data will only be
      stored once but be available for sampling with multiple sequence lengths
      from the respective reverb tables.
  
      **Note**: This observer is designed to work with py_drivers only, and does
      not support batches.
  
      Args:
        py_client: Python client for the reverb replay server.
        table_name: The table name(s) where samples will be written to.
        sequence_length: The sequence_length used to write to the given table.
        stride_length: The integer stride for the sliding window for overlapping
          sequences.  The default value of `1` creates an item for every window.
          Using `L = sequence_length` this means items are created for times `{0,
          1, .., L-1}, {1, 2, .., L}, ...`.  In contrast, `stride_length = L` will
          create an item only for disjoint windows `{0, 1, ..., L-1}, {L, ..., 2 *
          L - 1}, ...`.
        priority: Initial priority for new samples in the RB.
        pad_end_of_episodes: At the end of an episode, the cache is dropped by
          default. When `pad_end_of_episodes = True`, the cache gets padded with
          boundary steps (last->first) with `0` values everywhere and padded items
          of `sequence_length` are written to Reverb.
        tile_end_of_episodes: If `pad_end_of_episodes` is True then, the last
          padded item starts with a boundary step from the episode.  When this
          option is True the following items will be generated:  F, M, L, P M, L,
          P, P L, P, P, P  If False, only a single one will be generated:  F, M,
          L, P  For training recurrent models on environments where required
          information is only available at the start of the episode it is useful
          to set `tile_end_of_episodes=False` and the `sequence_length` to be the
          length of the longest episode.
  
      Raises:
        ValueError: If `tile_end_of_episodes` is set without
          `pad_end_of_episodes`.
      """
      if isinstance(table_name, Text):
          self._table_names = [table_name]
      else:
          self._table_names = table_name
      self._sequence_length = sequence_length
      self._stride_length = stride_length
      self._priority = priority
      self._pad_end_of_episodes = pad_end_of_episodes
      self._tile_end_of_episodes = tile_end_of_episodes
  
      if tile_end_of_episodes and not pad_end_of_episodes:
          raise ValueError(
              "Must set `pad_end_of_episodes=True` when using "
              "`tile_end_of_episodes`"
          )
  
      self._py_client = py_client
      # TODO(b/153700282): Use a single writer with max_sequence_length=max(...)
      # once Reverb Dataset with emit_timesteps=True returns properly shaped
      # sequences.
      self._writer = py_client.trajectory_writer(
          num_keep_alive_refs=sequence_length + 1, validate_items=False
      )
      self._cached_steps = 0
      self._last_trajectory = None
  
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 ReverbAddTrajectoryObserver object from inherited base classes: object with example: obj = ReverbAddTrajectoryObserver(py_client, table_name, sequence_length, stride_length, priority, pad_end_of_episodes, tile_end_of_episodes)