code: def get_detection_api_from_dataset(dataset):
      # Lorenzo: adapted to support LVIS and AvalancheDataset
      for _ in range(10):
          if isinstance(dataset, CocoDetection):
              break
          elif hasattr(dataset, "lvis_api"):
              break
          elif isinstance(dataset, Subset):
              dataset = dataset.dataset
          else:
              dataset = dataset._datasets[0]
  
      if isinstance(dataset, torchvision.datasets.CocoDetection):
          return dataset.coco
      if hasattr(dataset, "lvis_api"):
          return dataset.lvis_api
      return convert_to_coco_api(dataset)
  
file_path: avalanche/examples/tvdetection/engine.py
imports: import math
  import sys
  import time
  import torch
  import torchvision.models.detection.mask_rcnn
  from lvis import LVIS
  from pycocotools.coco import COCO
  from torch.utils.data import Subset
  from avalanche.benchmarks.utils import _make_taskaware_classification_dataset, _taskaware_classification_subset, _concat_taskaware_classification_datasets
  from examples.tvdetection.coco_eval import CocoEvaluator
  from examples.tvdetection.coco_utils import CocoDetection, convert_to_coco_api
  from examples.tvdetection.lvis_eval import LvisEvaluator
  from examples.tvdetection.utils import MetricLogger, SmoothedValue, reduce_dict
label_desc: Use image node_id 6 for calling a global function with example usage: get_detection_api_from_dataset(dataset) and returns: convert_to_coco_api, dataset, dataset