code: def testAddToStaleEpisodeIDIsAvoided(self):
      spec = specs.TensorSpec([], tf.int32, "action")
      replay_buffer = episodic_replay_buffer.EpisodicReplayBuffer(
          spec,
          capacity=1,
          begin_episode_fn=lambda _: False,
          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_0 = (
          episodic_replay_buffer.StatefulEpisodicReplayBuffer(
              replay_buffer, num_episodes=1
          )
      )
      replay_buffer_stateful_1 = (
          episodic_replay_buffer.StatefulEpisodicReplayBuffer(
              replay_buffer, num_episodes=1
          )
      )
      episode_id_var_0 = replay_buffer_stateful_0.episode_ids
      episode_id_var_1 = replay_buffer_stateful_1.episode_ids
  
      items_fn = replay_buffer.gather_all
  
      self.evaluate(tf.compat.v1.global_variables_initializer())
      self.evaluate(tf.compat.v1.local_variables_initializer())
  
      self.evaluate(replay_buffer_stateful_0.add_batch(a()))
      self.assertEqual(self.evaluate(episode_id_var_0), 0)
      self.assertAllClose(self.evaluate(items_fn())[0], [0])
  
      self.evaluate(replay_buffer_stateful_1.add_batch(a()))
      self.assertEqual(self.evaluate(episode_id_var_1), 1)
      self.assertAllClose(self.evaluate(items_fn())[0], [1])
  
      # Adding to episode 0 will be avoided as it is no longer there.
      self.evaluate(replay_buffer_stateful_0.add_batch(a()))
      self.assertEqual(self.evaluate(episode_id_var_0), 0)
      self.assertAllClose(self.evaluate(items_fn())[0], [1])
  
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 13 for calling the StatefulEpisodicReplayBufferTest obj's underlying member method code with example usage: obj.testAddToStaleEpisodeIDIsAvoided() without return types