code: def add_tracks(
      data,
      train_size=(256, 256),
      vflip=False,
      random_crop=True,
      tracks_to_sample=256,
      sampling_stride=4,
      max_seg_id=25,
      max_sampled_frac=0.1,
  ):
      """Track points in 2D using Kubric data.
  
      Args:
        data: Kubric data, including RGB/depth/object coordinate/segmentation
          videos and camera parameters.
        train_size: Cropped output will be at this resolution.  Ignored if
          random_crop is False.
        vflip: whether to vertically flip images and tracks (to test generalization)
        random_crop: Whether to randomly crop videos
        tracks_to_sample: Total number of tracks to sample per video.
        sampling_stride: For efficiency, query points are sampled from a random grid
          of this stride.
        max_seg_id: The maxium segment id in the video.
        max_sampled_frac: The maximum fraction of points to sample from each
          object, out of all points that lie on the sampling grid.
  
      Returns:
        A dict with the following keys:
        query_points:
          A set of queries, randomly sampled from the video (with a bias toward
          objects), of shape [num_points, 3].  Each point is [t, y, x], where
          t is time.  Points are in pixel/frame coordinates.
          [num_frames, height, width].
        target_points:
          The trajectory for each query point, of shape [num_points, num_frames, 3].
          Each point is [x, y].  Points are in pixel/frame coordinates.
        occlusion:
          Occlusion flag for each point, of shape [num_points, num_frames].  This is
          a boolean, where True means the point is occluded.
        video:
          The cropped video, normalized into the range [-1, 1]
  
      """
      shp = data["video"].shape.as_list()
      num_frames = shp[0]
      if any([s % sampling_stride != 0 for s in shp[:-1]]):
          raise ValueError(
              "All video dims must be a multiple of sampling_stride."
          )
  
      bbox = tf.constant(
          [0.0, 0.0, 1.0, 1.0], dtype=tf.float32, shape=[1, 1, 4]
      )
      min_area = 0.3
      max_area = 1.0
      min_aspect_ratio = 0.5
      max_aspect_ratio = 2.0
      if random_crop:
          crop_window = _get_distorted_bounding_box(
              jpeg_shape=shp[1:4],
              bbox=bbox,
              min_object_covered=min_area,
              aspect_ratio_range=(min_aspect_ratio, max_aspect_ratio),
              area_range=(min_area, max_area),
              max_attempts=20,
          )
      else:
          crop_window = tf.constant(
              [0, 0, shp[1], shp[2]], dtype=tf.int32, shape=[4]
          )
  
      query_points, target_points, occluded = track_points(
          data["object_coordinates"],
          data["depth"],
          data["metadata"]["depth_range"],
          data["segmentations"],
          data["normal"],
          data["instances"]["bboxes_3d"],
          data["instances"]["quaternions"],
          data["camera"]["focal_length"],
          data["camera"]["positions"],
          data["camera"]["quaternions"],
          data["camera"]["sensor_width"],
          crop_window,
          tracks_to_sample,
          sampling_stride,
          max_seg_id,
          max_sampled_frac,
      )
      video = data["video"]
  
      shp = video.shape.as_list()
      query_points.set_shape([tracks_to_sample, 3])
      target_points.set_shape([tracks_to_sample, num_frames, 2])
      occluded.set_shape([tracks_to_sample, num_frames])
  
      # Crop the video to the sampled window, in a way which matches the coordinate
      # frame produced the track_points functions.
      crop_window = crop_window / (
          np.array(shp[1:3] + shp[1:3]).astype(np.float32) - 1
      )
      crop_window = tf.tile(crop_window[tf.newaxis, :], [num_frames, 1])
      video = tf.image.crop_and_resize(
          video,
          tf.cast(crop_window, tf.float32),
          tf.range(num_frames),
          train_size,
      )
      if vflip:
          video = video[:, ::-1, :, :]
          target_points = target_points * np.array([1, -1])
          query_points = query_points * np.array([1, -1, 1])
      res = {
          "query_points": query_points,
          "target_points": target_points,
          "occluded": occluded,
          "video": video / (255.0 / 2.0) - 1.0,
      }
      return res
  
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 12 for calling a global function with example usage: add_tracks(data, train_size, vflip, random_crop, tracks_to_sample, sampling_stride, max_seg_id, max_sampled_frac) and returns: res