code: def save_result_coco_format(detection_data_path, pred, result_path):
      coco_dataset = COCODataset(detection_data_path)
      result_name, _ = os.path.splitext(result_path)
      result_path = result_name + ".json"
      coco_dataset.save_result(
          pred,
          from_coco_or_voc(detection_data_path, "test"),
          save_path=result_path,
      )
      logger.info(25, f"Saved detection result to {result_path}")
  
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 36 for calling a global function with example usage: save_result_coco_format(detection_data_path, pred, result_path) without return types