code: def _valid_range_ids(last_id, max_length, num_steps=None):
      """Returns the [min_val, max_val) range of ids.
  
      When num_steps is provided, [min_val, max_val+num_steps) are also valid ids.
  
      Args:
        last_id: The last id added to the buffer.
        max_length: The max length of each batch segment in the buffer.
        num_steps: Optional way to specify that how many ids need to be valid.
  
      Returns:
        A tuple (min_id, max_id) for the range [min_id, max_id) of valid ids.
      """
      if num_steps is None:
          num_steps = tf.constant(1, tf.int64)
  
      min_id_not_full = tf.constant(0, dtype=tf.int64)
      max_id_not_full = tf.maximum(last_id + 1 - num_steps + 1, 0)
  
      min_id_full = last_id + 1 - max_length
      max_id_full = last_id + 1 - num_steps + 1
  
      return (
          tf.where(last_id < max_length, min_id_not_full, min_id_full),
          tf.where(last_id < max_length, max_id_not_full, max_id_full),
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import gin
  import numpy
  import tensorflow
  from tf_agents.replay_buffers import replay_buffer
  from tf_agents.replay_buffers import table
  from tf_agents.specs import tensor_spec
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 1 for calling a global function with example usage: _valid_range_ids(last_id, max_length, num_steps) and returns: tf,  tf