code: def get_coco_api_from_dataset(dataset):
      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)
  
imports: import torch
  import torchvision
  import torch.utils.data
  from pycocotools.coco import COCO
label_desc: Use image node_id 2 for calling a global function with example usage: get_coco_api_from_dataset(dataset) and returns: convert_to_coco_api, dataset