code: def _build_annotations_index(
      annotations: NestedDict,
  ) -> Tuple[Dict[int, List[NestedDict]], Dict[int, NestedDict]]:
      """Builds some indices to make data generation more convenient."""
      video_id_to_annos = collections.defaultdict(list)
      videos = {}
      if "annotations" in annotations:
          for anno in annotations["annotations"]:
              video_id_to_annos[anno["video_id"]].append(anno)
      else:  # Testing or validation data contains no annotations.
          video_id_to_annos = {
              v["id"]: [] for v in annotations["videos"]
          }
      videos = {v["id"]: v for v in annotations["videos"]}
      return video_id_to_annos, videos
  
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 6 for calling a global function with example usage: _build_annotations_index(annotations) and returns: video_id_to_annos,  videos