code: def testSampleDoesNotCrossHead(self):
      np.random.seed(12345)
  
      data_spec = array_spec.ArraySpec((), np.int32)
      replay_buffer = py_uniform_replay_buffer.PyUniformReplayBuffer(
          data_spec=data_spec, capacity=10
      )
  
      # Seed RB with 5 elements to move head to position 5.
      for _ in range(5):
          replay_buffer.add_batch(np.array([0]))
  
      # Fill RB with elements 0-9.
      for i in range(10):
          replay_buffer.add_batch(np.array([i]))
  
      # Sample with num_steps = 2. We should never sample (9, 0) since this is an
      # invalid transition. With 1000 samples, the probability of sampling (9, 0)
      # if it were not protected against would be (1 - (9/10)^10000) ~= 1.
      sample_frequency = [0 for _ in range(10)]
      for _ in range(10000):
          (first, second) = replay_buffer.get_next(
              num_steps=2, time_stacked=False
          )
          self.assertNotEqual(np.array(9), first)
          self.assertNotEqual(np.array(0), second)
          sample_frequency[first] += 1
  
      # 0-9 should all have been sampled about 10000/9 ~= 1111. We allow a delta
      # of 150 off of 1111 -- the chance each sample frequency is within this
      # range is 99.9998% (computed using the pmf of the binomial distribution).
      # And since we fix the random seed, this test is repeatable.
      for i in range(9):
          self.assertAlmostEqual(
              10000 / 9, sample_frequency[i], delta=150
          )
  
imports: from __future__ import division
  from __future__ import unicode_literals
  import os
  from absl.testing import parameterized
  import numpy
  import tensorflow
  from tf_agents.replay_buffers import py_hashed_replay_buffer
  from tf_agents.replay_buffers import py_uniform_replay_buffer
  from tf_agents.specs import array_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 8 for calling the PyUniformReplayBufferTest obj's underlying member method code with example usage: obj.testSampleDoesNotCrossHead() without return types