code: def camera_rays_from_transformation_matrix(rays, transform_matrix):
      """Estimate ray origin and direction from transformation matrix.
  
      Args:
        rays: A tensor of shape `[A1, ..., An, N, 3]` where N is the number of rays.
        transform_matrix: A tensor of shape `[A1, ..., An, 4, 4]`.
      Returns:
        A tensor of shape `[A1, ..., An, N, 3]` representing the ray origin and
        a tensor of shape `[A1, ..., An, N, 3]` representing the ray direction.
      """
      rays_o = transform_matrix[..., :3, -1]  # [A1, ..., An, 3]
      rays_o = tf.expand_dims(rays_o, -2)  # [A1, ..., An, 1, 3]
      rays_o = tf.broadcast_to(
          rays_o, tf.shape(rays)
      )  # [A1, ..., An, N, 3]
      rot = transform_matrix[..., tf.newaxis, :3, :3]
      rays_d = tf.reduce_sum(
          tf.expand_dims(rays, axis=-2) * rot, axis=-1
      )
      return rays_o, rays_d
  
file_path: graphics/tensorflow_graphics/projects/radiance_fields/utils.py
imports: import math
  import tensorflow
  from tensorflow_graphics.geometry.transformation import rotation_matrix_3d
  from tensorflow_graphics.util import shape
label_desc: Use image node_id 6 for calling a global function with example usage: camera_rays_from_transformation_matrix(rays, transform_matrix) and returns: rays_o,  rays_d