code: def get_coco_api_from_dataset(dataset):
      # FIXME: This is... awful?
      for _ in range(10):
          if isinstance(dataset, torchvision.datasets.CocoDetection):
              break
          if isinstance(dataset, torch.utils.data.Subset):
              dataset = dataset.dataset
      if isinstance(dataset, torchvision.datasets.CocoDetection):
          return dataset.coco
      return convert_to_coco_api(dataset)
  
file_path: vision/references/detection/coco_utils.py
imports: import os
  import torch
  import torch.utils.data
  import torchvision
  import transforms
  from pycocotools import mask
  from pycocotools.coco import COCO
label_desc: Use image node_id 4 for calling a global function with example usage: get_coco_api_from_dataset(dataset) and returns: convert_to_coco_api, dataset