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: Resets the state of the observer.
  
  **Note**: Reset should be called only after all collection has finished
  in a standard workflow. No need to manually call reset between episodes.
  
  Args:
    write_cached_steps: boolean flag indicating whether we want to write the
      cached trajectory. When this argument is True, the function attempts to
      write the cached data before resetting (optionally with padding).
      Otherwise, the cached data gets dropped.
code: def reset(self, write_cached_steps: bool = True) -> None:
      """Resets the state of the observer.
  
      **Note**: Reset should be called only after all collection has finished
      in a standard workflow. No need to manually call reset between episodes.
  
      Args:
        write_cached_steps: boolean flag indicating whether we want to write the
          cached trajectory. When this argument is True, the function attempts to
          write the cached data before resetting (optionally with padding).
          Otherwise, the cached data gets dropped.
      """
      # Write the cached steps if requested and if the cache is not empty.
      if write_cached_steps and self._last_trajectory is not None:
          # Pad the cache and write all the cached steps into Reverb when padding is
          # enabled and `write_cached_steps` is set to `True`.
          if self._pad_end_of_episodes:
              zero_step = self._get_padding_step(self._last_trajectory)
  
              if self._tile_end_of_episodes:
                  pad_range = range(self._sequence_length - 1)
              else:
                  pad_range = range(
                      self._sequence_length - self._cached_steps
                  )
  
              for _ in pad_range:
                  self._get_writer().append(zero_step)
                  self._cached_steps += 1
                  self._write_cached_steps()
          # Write the cached trajectories without padding, if the cache contains
          # enough steps to write a full item.
          elif self._sequence_lengths_reached():
              self._write_cached_steps()
          else:
              raise ValueError(
                  "write_cached_steps is True, but not enough steps remain in the "
                  "cache to write an item with sequence_length={}, consider enabling "
                  "pad_end_of_episodes.".format(self._sequence_length)
              )
  
      self._cached_steps = 0
      self._last_trajectory = None
  
      if self._writer is None:
          self.open()
      else:
          self._writer.end_episode()
  
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 10 for calling the ReverbAddTrajectoryObserver obj's underlying member method code with example usage: obj.reset(write_cached_steps) without return types