class_docstr: Base class for Reverb adders.
class_docstr_tok: ["Base","class","for","Reverb","adders","."]
docstr: Record an action and the following timestep.
docstr_tok: ["Record","an","action","and","the","following","timestep","."]
code: def add(
      self,
      action: types.NestedArray,
      next_timestep: dm_env.TimeStep,
      extras: types.NestedArray = (),
  ):
      """Record an action and the following timestep."""
  
      if not self._add_first_called:
          raise ValueError(
              "adder.add_first must be called before adder.add."
          )
  
      # Add the timestep to the buffer.
      has_extras = (
          len(extras) > 0
          if isinstance(
              extras, Sized
          )  # pylint: disable=g-explicit-length-test
          else extras is not None
      )
      current_step = dict(
          # Observation was passed at the previous add call.
          action=action,
          reward=next_timestep.reward,
          discount=next_timestep.discount,
          # Start of episode indicator was passed at the previous add call.
          **({"extras": extras} if has_extras else {}),
      )
      self._writer.append(current_step)
  
      # Record the next observation and write.
      self._writer.append(
          dict(
              observation=next_timestep.observation,
              start_of_episode=next_timestep.first(),
          ),
          partial_step=True,
      )
      self._write()
  
      if next_timestep.last():
          # Complete the row by appending zeros to remaining open fields.
          # TODO(b/183945808): remove this when fields are no longer expected to be
          # of equal length on the learner side.
          dummy_step = tree.map_structure(np.zeros_like, current_step)
          self._writer.append(dummy_step)
          self._write_last()
          self.reset()
  
imports: import abc
  import time
  from typing import Callable, Iterable, Mapping, NamedTuple, Optional, Sized, Union, Tuple
  from absl import logging
  from acme import specs
  from acme import types
  from acme.adders import base
  import dm_env
  import numpy
  import reverb
  import tensorflow
  import tree
label_desc: Use image node_id 7 for calling the ReverbAdder obj's underlying member method code with example usage: obj.add(action, next_timestep, extras) without return types