tf_agents/metrics/tf_metrics.py [168:190]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    self._buffer = TFDeque(buffer_size, dtype)
    self._dtype = dtype
    self._return_accumulator = common.create_variable(
        initial_value=0, dtype=dtype, shape=(batch_size,), name='Accumulator')

  @common.function(autograph=True)
  def call(self, trajectory):
    # Zero out batch indices where a new episode is starting.
    self._return_accumulator.assign(
        tf.where(trajectory.is_first(), tf.zeros_like(self._return_accumulator),
                 self._return_accumulator))

    # Update accumulator with received rewards.
    self._return_accumulator.assign_add(trajectory.reward)

    # Add final returns to buffer.
    last_episode_indices = tf.squeeze(tf.where(trajectory.is_last()), axis=-1)
    for indx in last_episode_indices:
      self._buffer.add(self._return_accumulator[indx])

    return trajectory

  def result(self):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



tf_agents/metrics/tf_metrics.py [252:274]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    self._buffer = TFDeque(buffer_size, dtype)
    self._dtype = dtype
    self._return_accumulator = common.create_variable(
        initial_value=0, dtype=dtype, shape=(batch_size,), name='Accumulator')

  @common.function(autograph=True)
  def call(self, trajectory):
    # Zero out batch indices where a new episode is starting.
    self._return_accumulator.assign(
        tf.where(trajectory.is_first(), tf.zeros_like(self._return_accumulator),
                 self._return_accumulator))

    # Update accumulator with received rewards.
    self._return_accumulator.assign_add(trajectory.reward)

    # Add final returns to buffer.
    last_episode_indices = tf.squeeze(tf.where(trajectory.is_last()), axis=-1)
    for indx in last_episode_indices:
      self._buffer.add(self._return_accumulator[indx])

    return trajectory

  def result(self):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



