code: def _create_per_track_annotation(
      video: NestedDict,
      all_video_frame_paths: List[epath.PathLike],
      track_annotation: NestedDict,
      desired_height: Optional[int] = None,
      desired_width: Optional[int] = None,
  ) -> NestedDict:
      """Creates an anntation for a single object track.
  
      Args:
        video: The annotation for the video containing metadata info.
        all_video_frame_paths: List of all the frames belonging to the video.
        track_annotation: The annotation for a single object track in the video.
        desired_height: The height the video will be resized to. If None, no
          resizing occurs.
        desired_width: The width the video will be resized to. If None, no resizing.
          occurs.
  
      Returns:
        A data entry for a single object track for the video.
      """
      assert video["id"] == track_annotation["video_id"]
      height = desired_height or video["height"]
      width = desired_width or video["width"]
      per_track_anno = {}
  
      per_track_anno[
          "bboxes"
      ] = []  # Temporally ordered bounding boxes for track.
      per_track_anno[
          "frames"
      ] = []  # List of frames the track appears on.
      frames_with_labels = []
      for frame_idx, box in enumerate(track_annotation["bboxes"]):
          if box is None:
              continue
          frames_with_labels.append(frame_idx)
          per_track_anno["bboxes"].append(
              _convert_bbox(box, video["height"], video["width"])
          )
          # all_video_frame_paths is a superset of the annotated frames, and we
          # need to convert the index into the annotated frames to an index into
          # all_video_frame_paths.
          per_track_anno["frames"].append(
              _find_frame_index(
                  video["file_names"][frame_idx], all_video_frame_paths
              )
          )
      frames_with_labels = set(frames_with_labels)
  
      per_track_anno[
          "segmentations"
      ] = []  # Temporally ordered segmentations.
      for frame_idx, segmentation in enumerate(
          track_annotation["segmentations"]
      ):
          if segmentation is None:
              assert frame_idx not in frames_with_labels
              continue
          per_track_anno["segmentations"].append(
              _decode_segmentation(segmentation, video, height, width)
          )
          assert frame_idx in frames_with_labels
  
      per_track_anno[
          "areas"
      ] = []  # List of per-pixel segmentation areas.
      for frame_idx, area in enumerate(track_annotation["areas"]):
          if area is None:
              assert frame_idx not in frames_with_labels
              continue
          size_ratio = float(video["height"] * video["width"]) / (
              height * width
          )
          area = int(size_ratio * area)
          per_track_anno["areas"].append(area)
          assert frame_idx in frames_with_labels
  
      # TFDS ids are zero indexed whereas youtube-vis ids are not.
      per_track_anno["category"] = track_annotation["category_id"] - 1
      per_track_anno["is_crowd"] = track_annotation["iscrowd"]
  
      return per_track_anno
  
imports: from __future__ import annotations
  import collections
  import json
  import os
  from typing import Any, Dict, List, Optional, Tuple, Union
  from etils import epath
  import numpy
  import tensorflow_datasets.public_api
label_desc: Use image node_id 4 for calling a global function with example usage: _create_per_track_annotation(video, all_video_frame_paths, track_annotation, desired_height, desired_width) and returns: per_track_anno