code: def parse_detection_result(
      result: Optional[Union[Dict, np.ndarray]],
  ):
      if isinstance(result, np.ndarray):
          return {
              MAP: result[0],
              MEAN_AVERAGE_PRECISION: result[0],
              MAP_50: result[1],
              MAP_75: result[2],
              MAP_SMALL: result[3],
              MAP_MEDIUM: result[4],
              MAP_LARGE: result[5],
              MAR_1: result[6],
              MAR_10: result[7],
              MAR_100: result[8],
              MAR_SMALL: result[9],
              MAR_MEDIUM: result[10],
              MAR_LARGE: result[11],
          }
      else:
          result[MEAN_AVERAGE_PRECISION] = result[MAP]
          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 21 for calling a global function with example usage: parse_detection_result(result) and returns: dict, result