code: def random_rays(
      focal: tf.Tensor,
      principal_point: tf.Tensor,
      height: int,
      width: int,
      n_rays: int,
      margin: int = 0,
      name: str = "random_rays",
  ) -> Tuple[tf.Tensor, tf.Tensor]:
      """Sample rays at random pixel location from a perspective camera.
  
      Args:
        focal: A tensor of shape `[A1, ..., An, 2]` where the last dimension
          contains the fx and fy focal length values.
        principal_point: A tensor of shape `[A1, ..., An, 2]` where the last
          dimension contains the cx and cy principal point values.
        height: The height of the image plane in pixels
        width: The width of the image plane in pixels.
        n_rays: The number M of rays to sample.
        margin: The margin around the borders of the image.
        name: A name for this op that defaults to "random_rays".
  
      Returns:
        A tensor of shape `[A1, ..., An, M, 3]` with the ray directions and
        a tensor of shape `[A1, ..., An, M, 2]` with the pixel x, y locations.
      """
      with tf.name_scope(name):
          focal = tf.convert_to_tensor(value=focal)
          principal_point = tf.convert_to_tensor(value=principal_point)
  
          shape.check_static(
              tensor=focal, tensor_name="focal", has_dim_equals=(-1, 2)
          )
          shape.check_static(
              tensor=principal_point,
              tensor_name="principal_point",
              has_dim_equals=(-1, 2),
          )
          shape.compare_batch_dimensions(
              tensors=(focal, principal_point),
              tensor_names=("focal", "principal_point"),
              last_axes=-2,
              broadcast_compatible=True,
          )
  
          batch_dims = tf.shape(focal)[:-1]
          target_shape = tf.concat([batch_dims, [n_rays]], axis=0)
          random_x = tf.random.uniform(
              target_shape,
              minval=margin,
              maxval=width - margin,
              dtype=tf.int32,
          )
          random_y = tf.random.uniform(
              target_shape,
              minval=margin,
              maxval=height - margin,
              dtype=tf.int32,
          )
          pixels = tf.cast(
              tf.stack((random_x, random_y), axis=-1), tf.float32
          )
          rays = ray(
              pixels,
              tf.expand_dims(focal, -2),
              tf.expand_dims(principal_point, -2),
          )
          return rays, tf.cast(pixels, tf.int32)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  from typing import Tuple
  import tensorflow
  from tensorflow_graphics.geometry.representation import grid
  from tensorflow_graphics.util import asserts
  from tensorflow_graphics.util import export_api
  from tensorflow_graphics.util import safe_ops
  from tensorflow_graphics.util import shape
  from tensorflow_graphics.util import type_alias
label_desc: Use image node_id 7 for calling a global function with example usage: random_rays(focal, principal_point, height, width, n_rays, margin, name) and returns: rays,  tf