code: def testOverwriteOldEpisodes(self):
      num_adds = 5
      spec = specs.TensorSpec([], tf.int32, "action")
      replay_buffer = episodic_replay_buffer.EpisodicReplayBuffer(
          spec,
          capacity=3,
          begin_episode_fn=lambda _: True,
          end_episode_fn=lambda _: False,
      )
  
      a_state = common.create_variable("counter", -1, dtype=spec.dtype)
      a = lambda: tf.expand_dims(a_state.assign_add(1), 0)
  
      replay_buffer_stateful = (
          episodic_replay_buffer.StatefulEpisodicReplayBuffer(
              replay_buffer, num_episodes=1
          )
      )
      episode_id_var = replay_buffer_stateful.episode_ids
      if tf.executing_eagerly():
  
          def add():
              return replay_buffer_stateful.add_batch(a())
  
          items = replay_buffer.gather_all
      else:
          add = replay_buffer_stateful.add_batch(a())
          items = replay_buffer.gather_all()
      expected = [2, 3, 4]
  
      self.evaluate(tf.compat.v1.global_variables_initializer())
      self.evaluate(tf.compat.v1.local_variables_initializer())
  
      for i in range(num_adds):
          self.evaluate(add)
          self.assertEqual(self.evaluate(episode_id_var), i)
  
      items_ = self.evaluate(items)[0]
      self.assertAllClose(items_, expected)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tf_agents import specs
  from tf_agents.replay_buffers import episodic_replay_buffer
  from tf_agents.utils import common
  from tf_agents.utils import test_utils
  from tensorflow.python.ops import list_ops
label_desc: Use image node_id 12 for calling the StatefulEpisodicReplayBufferTest obj's underlying member method code with example usage: obj.testOverwriteOldEpisodes() and returns: replay_buffer_stateful