class_docstr: An episodic ReplayBuffer with Uniform sampling.
class_docstr_tok: ["An","episodic","ReplayBuffer","with","Uniform","sampling","."]
docstr: Samples episode ids from the replay buffer.
code: def _sample_episode_ids(
      self, shape, weigh_by_episode_length=False, seed=None
  ):
      """Samples episode ids from the replay buffer."""
      last_id = self._get_last_episode_id()
      assert_nonempty = tf.compat.v1.assert_non_negative(
          last_id,
          message=(
              "EpisodicReplayBuffer is empty. Make sure to add items "
              "before sampling the buffer."
          ),
      )
      if weigh_by_episode_length:
          # Sample episodes proportional to length.
          with tf.control_dependencies([assert_nonempty]):
              num_episodes = tf.minimum(
                  self._last_episode + 1, self._capacity
              )
              episode_lengths = self._episode_lengths[:num_episodes]
              logits = tf.math.log(tf.cast(episode_lengths, tf.float32))
              return tf.reshape(
                  tf.random.categorical(
                      [logits],  # shape is: [1, num_episodes]
                      num_samples=tf.reduce_prod(shape),
                      seed=seed,
                      dtype=tf.int64,
                  ),
                  shape,
              )
      else:
          min_val, max_val = _valid_range_ids(
              self._get_last_episode_id(), self._capacity
          )
          with tf.control_dependencies([assert_nonempty]):
              return tf.random.uniform(
                  shape,
                  minval=min_val,
                  maxval=max_val,
                  dtype=tf.int64,
                  seed=seed,
              )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import gin
  import tensorflow
  from tf_agents import specs
  from tf_agents.replay_buffers import episodic_table
  from tf_agents.replay_buffers import replay_buffer
  from tf_agents.replay_buffers import table
  from tf_agents.utils import common
  from tensorflow.python.data.util import nest
  from tensorflow.python.layers import utils
  from tensorflow.python.ops import list_ops
  from tensorflow.python.ops.distributions import util
label_desc: Use image node_id 22 for calling the EpisodicReplayBuffer obj's underlying member method code with example usage: obj._sample_episode_ids(shape, weigh_by_episode_length, seed) and returns: tf, tf