code: def stratified_1d(
      near: TensorLike,
      far: TensorLike,
      num_samples: int,
      name="stratified_1d",
  ) -> tf.Tensor:
      """Stratified sampling based on evenly-spaced bin size of an interval.
  
      Args:
        near: A tensor of shape `[A1, ... An]` containing the starting points of
          the sampling interval.
        far: A tensor of shape `[A1, ... An]` containing the ending points of
          the sampling interval.
        num_samples: The number M of points to be sampled.
        name:  A name for this op that defaults to "stratified_1d".
  
  
      Returns:
        A tensor of shape `[A1, ..., An, M]` indicating the M points on the ray
      """
      with tf.name_scope(name):
          near = tf.convert_to_tensor(near)
          far = tf.convert_to_tensor(far)
  
          shape.compare_batch_dimensions(
              tensors=(
                  tf.expand_dims(near, axis=-1),
                  tf.expand_dims(far, axis=-1),
              ),
              tensor_names=("near", "far"),
              last_axes=-1,
              broadcast_compatible=True,
          )
  
          bin_borders = tf.linspace(0.0, 1.0, num_samples + 1, axis=-1)
          bin_below = bin_borders[..., :-1]
          bin_above = bin_borders[..., 1:]
          target_shape = tf.concat(
              [tf.shape(near), [num_samples]], axis=-1
          )
          random_point_in_bin = tf.random.uniform(target_shape)
          z_values = (
              bin_below + (bin_above - bin_below) * random_point_in_bin
          )
          z_values = (
              tf.expand_dims(near, -1) * (1.0 - z_values)
              + tf.expand_dims(far, -1) * z_values
          )
          return z_values
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from tensorflow_graphics.util import export_api
  from tensorflow_graphics.util import safe_ops
  from tensorflow_graphics.util import shape
  from tensorflow_graphics.util.type_alias import TensorLike
label_desc: Use image node_id 4 for calling a global function with example usage: stratified_1d(near, far, num_samples, name) and returns: z_values