class_docstr: A Python-based replay buffer that supports uniform sampling.
  
  Writing and reading to this replay buffer is thread safe.
  
  This replay buffer can be subclassed to change the encoding used for the
  underlying storage by overriding _encoded_data_spec, _encode, _decode, and
  _on_delete.
class_docstr_tok: ["A","Python-based","replay","buffer","that","supports","uniform","sampling",".","Writing","and","reading","to","this","replay","buffer","is","thread","safe",".","This","replay","buffer","can","be","subclassed","to","change","the","encoding","used","for","the","underlying","storage","by","overriding","_encoded_data_spec",",","_encode",",","_decode",",","and","_on_delete","."]
code: def _get_next(
      self, sample_batch_size=None, num_steps=None, time_stacked=True
  ):
      num_steps_value = num_steps if num_steps is not None else 1
  
      def get_single():
          """Gets a single item from the replay buffer."""
          with self._lock:
              if self._np_state.size <= 0:
  
                  def empty_item(spec):
                      return np.empty(spec.shape, dtype=spec.dtype)
  
                  if num_steps is not None:
                      item = [
                          tf.nest.map_structure(
                              empty_item, self.data_spec
                          )
                          for n in range(num_steps)
                      ]
                      if time_stacked:
                          item = nest_utils.stack_nested_arrays(item)
                  else:
                      item = tf.nest.map_structure(
                          empty_item, self.data_spec
                      )
                  return item
              idx = np.random.randint(
                  self._np_state.size - num_steps_value + 1
              )
              if self._np_state.size == self._capacity:
                  # If the buffer is full, add cur_id (head of circular buffer) so that
                  # we sample from the range [cur_id, cur_id + size - num_steps_value].
                  # We will modulo the size below.
                  idx += self._np_state.cur_id
  
              if num_steps is not None:
                  # TODO(b/120242830): Try getting data from numpy in one shot rather
                  # than num_steps_value.
                  item = [
                      self._decode(
                          self._storage.get((idx + n) % self._capacity)
                      )
                      for n in range(num_steps)
                  ]
              else:
                  item = self._decode(
                      self._storage.get(idx % self._capacity)
                  )
  
          if num_steps is not None and time_stacked:
              item = nest_utils.stack_nested_arrays(item)
          return item
  
      if sample_batch_size is None:
          return get_single()
      else:
          samples = [get_single() for _ in range(sample_batch_size)]
          return nest_utils.stack_nested_arrays(samples)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import threading
  import numpy
  import tensorflow
  from tf_agents.replay_buffers import replay_buffer
  from tf_agents.specs import array_spec
  from tf_agents.utils import nest_utils
  from tf_agents.utils import numpy_storage
label_desc: Use image node_id 9 for calling the PyUniformReplayBuffer obj's underlying member method code with example usage: obj._get_next(sample_batch_size, num_steps, time_stacked) and returns: item, get_single, nest_utils, item, np