code: def get_camera_matrices(
      cam_focal_length,
      cam_positions,
      cam_quaternions,
      cam_sensor_width,
      input_size,
      num_frames=None,
  ):
      """Tf function that converts camera positions into projection matrices."""
      intrinsics = []
      matrix_world = []
      assert cam_quaternions.shape[0] == num_frames
      for frame_idx in range(cam_quaternions.shape[0]):
          focal_length = tf.cast(cam_focal_length, tf.float32)
          sensor_width = tf.cast(cam_sensor_width, tf.float32)
          f_x = focal_length / sensor_width
          f_y = (
              focal_length
              / sensor_width
              * input_size[0]
              / input_size[1]
          )
          p_x = 0.5
          p_y = 0.5
          intrinsics.append(
              tf.stack(
                  [
                      tf.stack([f_x, 0.0, -p_x]),
                      tf.stack([0.0, -f_y, -p_y]),
                      tf.stack([0.0, 0.0, -1.0]),
                  ]
              )
          )
  
          position = cam_positions[frame_idx]
          quat = cam_quaternions[frame_idx]
          rotation_matrix = rotation_matrix_3d.from_quaternion(
              tf.concat([quat[1:], quat[0:1]], axis=0)
          )
          transformation = tf.concat(
              [rotation_matrix, position[:, tf.newaxis]],
              axis=1,
          )
          transformation = tf.concat(
              [
                  transformation,
                  tf.constant([0.0, 0.0, 0.0, 1.0])[tf.newaxis, :],
              ],
              axis=0,
          )
          matrix_world.append(transformation)
  
      return (
          tf.cast(tf.stack(intrinsics), tf.float32),
          tf.cast(tf.stack(matrix_world), tf.float32),
      )
  
imports: import functools
  import itertools
  import matplotlib.pyplot
  import mediapy
  import numpy
  import tensorflow.compat.v1
  import tensorflow_datasets
  from tensorflow_graphics.geometry.transformation import rotation_matrix_3d
label_desc: Use image node_id 5 for calling a global function with example usage: get_camera_matrices(cam_focal_length, cam_positions, cam_quaternions, cam_sensor_width, input_size, num_frames) and returns: tf,  tf