code: def _build_annotations_index(
      annotations: NestedDict,
  ) -> Tuple[NestedDict, NestedDict, NestedDict, NestedDict]:
      """Builds several dictionaries to aid in looking up annotations."""
      vids = {x["id"]: x for x in annotations["videos"]}
      images = {x["id"]: x for x in annotations["images"]}
      ann_to_images = {}
      track_to_anns = collections.defaultdict(list)
      vid_to_tracks = collections.defaultdict(list)
      for track in annotations["tracks"]:
          vid_to_tracks[track["video_id"]].append(track)
      for ann in annotations["annotations"]:
          ann_to_images[ann["id"]] = images[ann["image_id"]]
          track_to_anns[ann["track_id"]].append(ann)
      return vids, ann_to_images, track_to_anns, vid_to_tracks
  
imports: from __future__ import annotations
  import collections
  import json
  import os
  from typing import Any, Dict, Optional, Tuple
  from etils import epath
  import numpy
  import tensorflow_datasets.public_api
label_desc: Use image node_id 1 for calling a global function with example usage: _build_annotations_index(annotations) and returns: vids,  ann_to_images,  track_to_anns,  vid_to_tracks