code: def cocoeval(
      outputs: List,
      data: pd.DataFrame,
      anno_file: str,
      cache_path: str,
      metrics: Optional[Union[str, List]],
      tool="pycocotools",
  ):
      """
      Evaluate predictor's output using mAP metrics per COCO's standard.
  
      Parameters
      ----------
      outputs
          The predictor's output. It is a list with length equals number of images.
      data
          The input data.
      anno_file
          The path to COCO format json annotation file.
      cache_path
          The cache path to store prediction result in COCO format.
      metrics
          The name of metrics to be reported.
      tool
          Use the mAP implementation of "pycocotools" or "torchmetrics".
  
      Returns
      -------
      The mAP result.
      """
      if (not tool) or tool == "pycocotools":
          result = cocoeval_pycocotools(
              outputs, data, anno_file, cache_path
          )
      elif tool == "torchmetrics":
          result = cocoeval_torchmetrics(outputs)
      else:
          raise ValueError(f"Unsupported eval_tool: {tool}")
  
      result = parse_detection_result(result)
  
      if metrics:
          if isinstance(metrics, str) and metrics.lower() in result:
              return {metrics.lower(): result[metrics.lower()]}
          elif isinstance(metrics, list):
              return {
                  metric.lower(): result[metric.lower()]
                  for metric in metrics
              }
  
      return result
  
imports: import json
  import logging
  import os
  import warnings
  from pathlib import Path
  from typing import Dict, Iterable, List, Optional, Union
  import defusedxml.ElementTree
  import numpy
  import pandas
  import PIL
  from torchmetrics.detection.mean_ap import MeanAveragePrecision
  from ..constants import BBOX, LABEL, MAP, MAP_50, MAP_75, MAP_LARGE, MAP_MEDIUM, MAP_SMALL, MAR_1, MAR_10, MAR_100, MAR_LARGE, MAR_MEDIUM, MAR_SMALL, MEAN_AVERAGE_PRECISION
  from .download import download, is_url
label_desc: Use image node_id 22 for calling a global function with example usage: cocoeval(outputs, data, anno_file, cache_path, metrics, tool) and returns: result, dict, unknown