class_docstr: Coco captions dataset with the splits defined by Karpathy and Li 2015.
docstr: Returns SplitGenerators.
docstr_tok: ["Returns","SplitGenerators","."]
code: def _split_generators(self, dl_manager):
      """Returns SplitGenerators."""
  
      # Only keep the coco train and validation sets.
      coco_splits = {
          split.name: split
          for split in super(CocoCaptions, self)._split_generators(
              dl_manager
          )
      }
      coco_train_split = coco_splits[tfds.Split.TRAIN]
      coco_val_split = coco_splits[tfds.Split.VALIDATION]
  
      urls = {}
      urls["karpathy_and_li_splits"] = (
          "https://cs.stanford.edu/people/karpathy/deepimagesent/"
          "caption_datasets.zip"
      )
      extracted_paths = dl_manager.download_and_extract(urls)
  
      # Load split definitions.
      captions_json_path = os.path.join(
          extracted_paths["karpathy_and_li_splits"], "dataset_coco.json"
      )
      with epath.Path(captions_json_path).open() as f:
          annotations = json.load(f)["images"]
  
      # split => image filename => annotations
      annotation_maps = collections.defaultdict(dict)
      for annotation in annotations:
          split = annotation["split"]
          image_filename = annotation["filename"]
          annotation_maps[split][image_filename] = annotation
  
      return [
          tfds.core.SplitGenerator(
              "train",
              gen_kwargs=dict(
                  image_filename_to_annotations=annotation_maps[
                      "train"
                  ],
                  coco_gen_kwargs=coco_train_split.gen_kwargs,
              ),
          ),
          tfds.core.SplitGenerator(
              "val",
              gen_kwargs=dict(
                  image_filename_to_annotations=annotation_maps["val"],
                  coco_gen_kwargs=coco_val_split.gen_kwargs,
              ),
          ),
          tfds.core.SplitGenerator(
              "test",
              gen_kwargs=dict(
                  image_filename_to_annotations=annotation_maps["test"],
                  coco_gen_kwargs=coco_val_split.gen_kwargs,
              ),
          ),
          tfds.core.SplitGenerator(
              "restval",
              gen_kwargs=dict(
                  image_filename_to_annotations=annotation_maps[
                      "restval"
                  ],
                  coco_gen_kwargs=coco_val_split.gen_kwargs,
              ),
          ),
      ]
  
file_path: datasets/tensorflow_datasets/object_detection/coco_captions.py
imports: from __future__ import annotations
  import collections
  import json
  import os
  from absl import logging
  from etils import epath
  import numpy
  from tensorflow_datasets.object_detection import coco
  import tensorflow_datasets.public_api
label_desc: Use image node_id 2 for calling the CocoCaptions obj's underlying member method code with example usage: obj._split_generators(dl_manager) and returns: list