code: def _get_filename_to_label_map(annotations_path, dataset_name, split):
      """Returns a mapping from image filenames to labels, for the given split."""
      filename_to_label = {}
      if split == "test":
          filepath = os.path.join(
              annotations_path, dataset_name + "_test_stripped.json"
          )
      else:
          filepath = os.path.join(
              annotations_path, dataset_name + "_%s.json" % split
          )
      prefix = "data/"
      with tf.io.gfile.GFile(filepath, mode="r") as f:
          annotations = json.load(f)
          if split == "test":
              # For test, labels are unknown.
              for example_info in annotations["images"]:
                  image_filename = example_info["file_name"]
                  image_filename = image_filename[len(prefix) :]
                  filename_to_label[image_filename] = -1
          else:
              # Load a map from category ID to label index.
              category_id_to_label = {}
              for i, category_info in enumerate(
                  annotations["categories"]
              ):
                  category_id_to_label[category_info["id"]] = i
              # Load a map from image ID to image filename.
              image_id_to_filename = {}
              for example_info in annotations["images"]:
                  image_id_to_filename[
                      example_info["id"]
                  ] = example_info["file_name"]
              # Load the map from image filename to label.
              for example_info in annotations["annotations"]:
                  image_filename = image_id_to_filename[
                      example_info["image_id"]
                  ]
                  image_filename = image_filename[len(prefix) :]
                  label = category_id_to_label[
                      example_info["category_id"]
                  ]
                  filename_to_label[image_filename] = label
      return filename_to_label
  
file_path: datasets/tensorflow_datasets/image_classification/visual_domain_decathlon.py
imports: import json
  import os
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  import tensorflow_datasets.public_api
label_desc: Use image node_id 2 for calling a global function with example usage: _get_filename_to_label_map(annotations_path, dataset_name, split) and returns: filename_to_label