code: def _preprocess_annotations(
      annotations_file: str, id_map: Dict[int, int]
  ) -> NestedDict:
      """Preprocesses the data to group together some category labels."""
      with epath.Path(annotations_file).open("r") as f:
          annotations = json.load(f)
      for ann in annotations["annotations"] + annotations["tracks"]:
          ann["category_id"] = id_map[ann["category_id"]]
  
      for ann in annotations["videos"]:
          filtered_neg_ids = []
          for neg_cat_id in ann["neg_category_ids"]:
              if neg_cat_id in id_map:
                  filtered_neg_ids.append(id_map[neg_cat_id])
          ann["neg_category_ids"] = filtered_neg_ids
          filtered_not_exhaustive_ids = []
  
          for not_exhaustive_id in ann["not_exhaustive_category_ids"]:
              if not_exhaustive_id in id_map:
                  filtered_not_exhaustive_ids.append(
                      id_map[not_exhaustive_id]
                  )
          ann[
              "not_exhaustive_category_ids"
          ] = filtered_not_exhaustive_ids
      # The frame index in the image starts at an arbitrary number. Make it
      # zero indexed.
      vid_to_frame_start = collections.defaultdict(lambda: np.inf)
      for image in annotations["images"]:
          vid = image["video_id"]
          vid_to_frame_start[vid] = min(
              vid_to_frame_start[vid], image["frame_index"]
          )
      for image in annotations["images"]:
          image["frame_index"] -= vid_to_frame_start[image["video_id"]]
      return annotations
  
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 5 for calling a global function with example usage: _preprocess_annotations(annotations_file, id_map) and returns: annotations