docstr: Create a replay buffer, add items to it, and collect from its dataset.
docstr_tok: ["Create","a","replay","buffer",",","add","items","to","it",",","and","collect","from","its","dataset","."]
code: def _create_collect_rb_dataset(
      self,
      max_length,
      buffer_batch_size,
      num_adds,
      sample_batch_size,
      num_steps=None,
  ):
      """Create a replay buffer, add items to it, and collect from its dataset."""
      spec = specs.TensorSpec([], tf.int32, "action")
      replay_buffer = tf_uniform_replay_buffer.TFUniformReplayBuffer(
          spec, batch_size=buffer_batch_size, max_length=max_length
      )
  
      ds = replay_buffer.as_dataset(
          single_deterministic_pass=True,
          sample_batch_size=sample_batch_size,
          num_steps=num_steps,
      )
      if tf.executing_eagerly():
          ix = [0]
  
          def add_op():
              replay_buffer.add_batch(
                  10 * tf.range(buffer_batch_size) + ix[0]
              )
              ix[0] += 1
  
          itr = iter(ds)
          get_next = lambda: next(itr)
      else:
          actions = 10 * tf.range(buffer_batch_size) + tf.Variable(
              0
          ).count_up_to(9)
          add_op = replay_buffer.add_batch(actions)
          itr = tf.compat.v1.data.make_initializable_iterator(ds)
          get_next = itr.get_next()
  
      self.evaluate(tf.compat.v1.global_variables_initializer())
  
      for _ in range(num_adds):
          # Add 10*range(buffer_batch_size) then 1 + 10*range(buffer_batch_size), ..
          # The actual episodes are:
          #   [0, 1, 2, ...],
          #   [10, 11, 12, ...],
          #   [20, 21, 22, ...]
          #   ... (buffer_batch_size of these)
          self.evaluate(add_op)
  
      rb_values = []
      if not tf.executing_eagerly():
          self.evaluate(itr.initializer)
      try:
          while True:
              rb_values.append(self.evaluate(get_next)[0].tolist())
      except (tf.errors.OutOfRangeError, StopIteration):
          pass
  
      return replay_buffer, rb_values
  
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 tf_uniform_replay_buffer
  from tf_agents.utils import common
  from tf_agents.utils import test_utils
label_desc: Use image node_id 19 for calling the TFUniformReplayBufferTest obj's underlying member method code with example usage: obj._create_collect_rb_dataset(max_length, buffer_batch_size, num_adds, sample_batch_size, num_steps) and returns: replay_buffer,  rb_values