class_docstr: An adder which adds sequences of fixed length.
class_docstr_tok: ["An","adder","which","adds","sequences","of","fixed","length","."]
code: def _maybe_create_item(
      self,
      sequence_length: int,
      *,
      end_of_episode: bool = False,
      force: bool = False,
  ):
      # Check conditions under which a new item is created.
      first_write = self._writer.episode_steps == sequence_length
      # NOTE(bshahr): the following line assumes that the only way sequence_length
      # is less than self._sequence_length, is if the episode is shorter than
      # self._sequence_length.
      period_reached = (
          self._writer.episode_steps > self._sequence_length
          and (
              (self._writer.episode_steps - self._sequence_length)
              % self._period
              == 0
          )
      )
  
      if not first_write and not period_reached and not force:
          return
  
      # TODO(b/183945808): will need to change to adhere to the new protocol.
      if not end_of_episode:
          get_traj = operator.itemgetter(
              slice(-sequence_length - 1, -1)
          )
      else:
          get_traj = operator.itemgetter(slice(-sequence_length, None))
  
      history = self._writer.history
      trajectory = base.Trajectory(
          **tree.map_structure(get_traj, history)
      )
  
      # Compute priorities for the buffer.
      table_priorities = utils.calculate_priorities(
          self._priority_fns, trajectory
      )
  
      # Create a prioritized item for each table.
      for table_name, priority in table_priorities.items():
          self._writer.create_item(table_name, priority, trajectory)
          self._writer.flush(self._max_in_flight_items)
  
imports: import enum
  import operator
  from typing import Iterable, Optional
  from acme import specs
  from acme import types
  from acme.adders.reverb import base
  from acme.adders.reverb import utils
  import numpy
  import reverb
  import tensorflow
  import tree
label_desc: Use image node_id 5 for calling the SequenceAdder obj's underlying member method code with example usage: obj._maybe_create_item(sequence_length) without return types