class_docstr: An adder which adds sequences of fixed length.
class_docstr_tok: ["An","adder","which","adds","sequences","of","fixed","length","."]
code: def _write_last(self):
      # Maybe determine the delta to the next time we would write a sequence.
      if self._end_of_episode_behavior in (
          EndBehavior.TRUNCATE,
          EndBehavior.ZERO_PAD,
      ):
          delta = self._sequence_length - self._writer.episode_steps
          if delta < 0:
              delta = (self._period + delta) % self._period
  
      # Handle various end-of-episode cases.
      if self._end_of_episode_behavior is EndBehavior.CONTINUE:
          self._maybe_create_item(
              self._sequence_length, end_of_episode=True
          )
  
      elif self._end_of_episode_behavior is EndBehavior.WRITE:
          # Drop episodes that are too short.
          if self._writer.episode_steps < self._sequence_length:
              return
          self._maybe_create_item(
              self._sequence_length, end_of_episode=True, force=True
          )
  
      elif self._end_of_episode_behavior is EndBehavior.TRUNCATE:
          self._maybe_create_item(
              self._sequence_length - delta,
              end_of_episode=True,
              force=True,
          )
  
      elif self._end_of_episode_behavior is EndBehavior.ZERO_PAD:
          zero_step = tree.map_structure(
              lambda x: np.zeros_like(x[-2].numpy()),
              self._writer.history,
          )
          for _ in range(delta):
              self._writer.append(zero_step)
  
          self._maybe_create_item(
              self._sequence_length, end_of_episode=True, force=True
          )
      else:
          raise ValueError(
              f"Unhandled end of episode behavior: {self._end_of_episode_behavior}."
              " This should never happen, please contact Acme dev team."
          )
  
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 4 for calling the SequenceAdder obj's underlying member method code with example usage: obj._write_last() without return types