code: def _random_uniform_int(
      shape, outer_dims, minval, maxval, dtype, seed=None
  ):
      """Iterates over n-d tensor minval, maxval limits to sample uniformly."""
      # maxval in BoundedTensorSpec is bound inclusive.
      # tf.random_uniform is upper bound exclusive, +1 to fix the sampling
      # behavior.
      # However +1 could cause overflow, in such cases we use the original maxval.
      maxval = np.broadcast_to(maxval, minval.shape).astype(
          dtype.as_numpy_dtype
      )
      minval = np.broadcast_to(minval, maxval.shape).astype(
          dtype.as_numpy_dtype
      )
  
      sampling_maxval = maxval
      if dtype.is_integer:
          sampling_maxval = np.where(
              maxval < dtype.max, maxval + 1, maxval
          )
  
      if not np.all(shape[-len(minval.shape) :] == minval.shape):
          raise ValueError(
              "%s == shape[-%d:] != minval.shape == %s.  shape == %s."
              % (
                  shape[len(minval.shape) :],
                  len(minval.shape),
                  minval.shape,
                  shape,
              )
          )
  
      # Example:
      #  minval = [1.0, 2.0]
      #  shape = [3, 2]
      #  outer_dims = [5]
      # Sampling becomes:
      #  sample [5, 3] for minval 1.0
      #  sample [5, 3] for minval 2.0
      #  stack on innermost axis to get [5, 3, 2]
      #  reshape to get [5, 3, 2]
      samples = []
      shape = tf.convert_to_tensor(shape, dtype=tf.int32)
      sample_shape = tf.concat(
          (outer_dims, shape[: -len(minval.shape)]), axis=0
      )
      full_shape = tf.concat((outer_dims, shape), axis=0)
      for single_min, single_max in zip(
          minval.flat, sampling_maxval.flat
      ):
          samples.append(
              tf.random.uniform(
                  shape=sample_shape,
                  minval=single_min,
                  maxval=single_max,
                  dtype=dtype,
                  seed=seed,
              )
          )
      samples = tf.stack(samples, axis=-1)
      samples = tf.reshape(samples, full_shape)
      return samples
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  from typing import Union
  import numpy
  import tensorflow
  import tensorflow_probability
  from tf_agents.specs import array_spec
  from tf_agents.typing import types
  from google.protobuf import text_format
  from tensorflow.core.protobuf import struct_pb2
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.saved_model import nested_structure_coder
label_desc: Use image node_id 10 for calling a global function with example usage: _random_uniform_int(shape, outer_dims, minval, maxval, dtype, seed) and returns: samples