class_docstr: An adder which adds sequences of fixed length.
class_docstr_tok: ["An","adder","which","adds","sequences","of","fixed","length","."]
docstr: Makes a SequenceAdder instance.
  
  Args:
    client: See docstring for BaseAdder.
    sequence_length: The fixed length of sequences we wish to add.
    period: The period with which we add sequences. If less than
      sequence_length, overlapping sequences are added. If equal to
      sequence_length, sequences are exactly non-overlapping.
    delta_encoded: If `True` (False by default) enables delta encoding, see
      `Client` for more information.
    priority_fns: See docstring for BaseAdder.
    max_in_flight_items: The maximum number of items allowed to be "in flight"
      at the same time. See `block_until_num_items` in
      `reverb.TrajectoryWriter.flush` for more info.
    end_of_episode_behavior:  Determines how sequences at the end of the
      episode are handled (default `EndOfEpisodeBehavior.ZERO_PAD`). See
      the docstring for `EndOfEpisodeBehavior` for more information.
    chunk_length: Deprecated and unused.
    pad_end_of_episode: If True (default) then upon end of episode the current
      sequence will be padded (with observations, actions, etc... whose values
      are 0) until its length is `sequence_length`. If False then the last
      sequence in the episode may have length less than `sequence_length`.
    break_end_of_episode: If 'False' (True by default) does not break
      sequences on env reset. In this case 'pad_end_of_episode' is not used.
    validate_items: Whether to validate items against the table signature
      before they are sent to the server. This requires table signature to be
      fetched from the server and cached locally.
docstr_tok: ["Makes","a","SequenceAdder","instance",".","Args",":","client",":","See","docstring","for","BaseAdder",".","sequence_length",":","The","fixed","length","of","sequences","we","wish","to","add",".","period",":","The","period","with","which","we","add","sequences",".","If","less","than","sequence_length",",","overlapping","sequences","are","added",".","If","equal","to","sequence_length",",","sequences","are","exactly","non-overlapping",".","delta_encoded",":","If","`","True","`","(","False","by","default",")","enables","delta","encoding",",","see","`","Client","`","for","more","information",".","priority_fns",":","See","docstring","for","BaseAdder",".","max_in_flight_items",":","The","maximum","number","of","items","allowed","to","be","``","in","flight","''","at","the","same","time",".","See","`","block_until_num_items","`","in","`","reverb.TrajectoryWriter.flush","`","for","more","info",".","end_of_episode_behavior",":","Determines","how","sequences","at","the","end","of","the","episode","are","handled","(","default","`","EndOfEpisodeBehavior.ZERO_PAD","`",")",".","See","the","docstring","for","`","EndOfEpisodeBehavior","`","for","more","information",".","chunk_length",":","Deprecated","and","unused",".","pad_end_of_episode",":","If","True","(","default",")","then","upon","end","of","episode","the","current","sequence","will","be","padded","(","with","observations",",","actions",",","etc","...","whose","values","are","0",")","until","its","length","is","`","sequence_length","`",".","If","False","then","the","last","sequence","in","the","episode","may","have","length","less","than","`","sequence_length","`",".","break_end_of_episode",":","If","'False","'","(","True","by","default",")","does","not","break","sequences","on","env","reset",".","In","this","case","'pad_end_of_episode","'","is","not","used",".","validate_items",":","Whether","to","validate","items","against","the","table","signature","before","they","are","sent","to","the","server",".","This","requires","table","signature","to","be","fetched","from","the","server","and","cached","locally","."]
code: def __init__(
      self,
      client: reverb.Client,
      sequence_length: int,
      period: int,
      *,
      delta_encoded: bool = False,
      priority_fns: Optional[base.PriorityFnMapping] = None,
      max_in_flight_items: Optional[int] = 2,
      end_of_episode_behavior: Optional[EndBehavior] = None,
      # Deprecated kwargs.
      chunk_length: Optional[int] = None,
      pad_end_of_episode: Optional[bool] = None,
      break_end_of_episode: Optional[bool] = None,
      validate_items: bool = True,
  ):
      """Makes a SequenceAdder instance.
  
      Args:
        client: See docstring for BaseAdder.
        sequence_length: The fixed length of sequences we wish to add.
        period: The period with which we add sequences. If less than
          sequence_length, overlapping sequences are added. If equal to
          sequence_length, sequences are exactly non-overlapping.
        delta_encoded: If `True` (False by default) enables delta encoding, see
          `Client` for more information.
        priority_fns: See docstring for BaseAdder.
        max_in_flight_items: The maximum number of items allowed to be "in flight"
          at the same time. See `block_until_num_items` in
          `reverb.TrajectoryWriter.flush` for more info.
        end_of_episode_behavior:  Determines how sequences at the end of the
          episode are handled (default `EndOfEpisodeBehavior.ZERO_PAD`). See
          the docstring for `EndOfEpisodeBehavior` for more information.
        chunk_length: Deprecated and unused.
        pad_end_of_episode: If True (default) then upon end of episode the current
          sequence will be padded (with observations, actions, etc... whose values
          are 0) until its length is `sequence_length`. If False then the last
          sequence in the episode may have length less than `sequence_length`.
        break_end_of_episode: If 'False' (True by default) does not break
          sequences on env reset. In this case 'pad_end_of_episode' is not used.
        validate_items: Whether to validate items against the table signature
          before they are sent to the server. This requires table signature to be
          fetched from the server and cached locally.
      """
      del chunk_length
      super().__init__(
          client=client,
          # We need an additional space in the buffer for the partial step the
          # base.ReverbAdder will add with the next observation.
          max_sequence_length=sequence_length + 1,
          delta_encoded=delta_encoded,
          priority_fns=priority_fns,
          max_in_flight_items=max_in_flight_items,
          validate_items=validate_items,
      )
  
      if pad_end_of_episode and not break_end_of_episode:
          raise ValueError(
              "Can't set pad_end_of_episode=True and break_end_of_episode=False at"
              " the same time, since those behaviors are incompatible."
          )
  
      self._period = period
      self._sequence_length = sequence_length
  
      if end_of_episode_behavior and (
          pad_end_of_episode is not None
          or break_end_of_episode is not None
      ):
          raise ValueError(
              "Using end_of_episode_behavior and either "
              "pad_end_of_episode or break_end_of_episode is not permitted. "
              "Please use only end_of_episode_behavior instead."
          )
  
      # Set pad_end_of_episode and break_end_of_episode to default values.
      if end_of_episode_behavior is None and pad_end_of_episode is None:
          pad_end_of_episode = True
      if (
          end_of_episode_behavior is None
          and break_end_of_episode is None
      ):
          break_end_of_episode = True
  
      self._end_of_episode_behavior = EndBehavior.ZERO_PAD
      if (
          pad_end_of_episode is not None
          or break_end_of_episode is not None
      ):
          if not break_end_of_episode:
              self._end_of_episode_behavior = EndBehavior.CONTINUE
          elif break_end_of_episode and pad_end_of_episode:
              self._end_of_episode_behavior = EndBehavior.ZERO_PAD
          elif break_end_of_episode and not pad_end_of_episode:
              self._end_of_episode_behavior = EndBehavior.TRUNCATE
          else:
              raise ValueError(
                  "Reached an unexpected configuration of the SequenceAdder "
                  f"with break_end_of_episode={break_end_of_episode} "
                  f"and pad_end_of_episode={pad_end_of_episode}."
              )
      elif isinstance(end_of_episode_behavior, EndBehavior):
          self._end_of_episode_behavior = end_of_episode_behavior
      else:
          raise ValueError(
              "end_of_episod_behavior must be an instance of "
              f"EndBehavior, received {end_of_episode_behavior}."
          )
  
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 1 to create a new SequenceAdder object from inherited base classes: base with example: obj = SequenceAdder(client, sequence_length, period)