code: def _cocoeval_summarize(
      cocoeval,
      ap=1,
      iouThr=None,
      catIdx=None,
      areaRng="all",
      maxDets=100,
      catName="",
      nameStrLen=None,
  ):
      p = cocoeval.params
      if catName:
          iStr = " {:<18} {} {:<{nameStrLen}} @[ IoU={:<9} | area={:>6s} | maxDets={:>3d} ] = {:0.3f}"
          nameStr = catName
      else:
          iStr = " {:<18} {} @[ IoU={:<9} | area={:>6s} | maxDets={:>3d} ] = {:0.3f}"
      titleStr = "Average Precision" if ap == 1 else "Average Recall"
      typeStr = "(AP)" if ap == 1 else "(AR)"
      iouStr = (
          "{:0.2f}:{:0.2f}".format(p.iouThrs[0], p.iouThrs[-1])
          if iouThr is None
          else "{:0.2f}".format(iouThr)
      )
  
      aind = [
          i for i, aRng in enumerate(p.areaRngLbl) if aRng == areaRng
      ]
      mind = [i for i, mDet in enumerate(p.maxDets) if mDet == maxDets]
      if ap == 1:
          # dimension of precision: [TxRxKxAxM]
          s = cocoeval.eval["precision"]
          # IoU
          if iouThr is not None:
              t = np.where(iouThr == p.iouThrs)[0]
              s = s[t]
          if catIdx is not None:
              s = s[:, :, catIdx, aind, mind]
          else:
              s = s[:, :, :, aind, mind]
      else:
          # dimension of recall: [TxKxAxM]
          s = cocoeval.eval["recall"]
          if iouThr is not None:
              t = np.where(iouThr == p.iouThrs)[0]
              s = s[t]
          if catIdx is not None:
              s = s[:, catIdx, aind, mind]
          else:
              s = s[:, :, aind, mind]
      if len(s[s > -1]) == 0:
          mean_s = -1
      else:
          mean_s = np.mean(s[s > -1])
      if catName:
          print(
              iStr.format(
                  titleStr,
                  typeStr,
                  nameStr,
                  iouStr,
                  areaRng,
                  maxDets,
                  mean_s,
                  nameStrLen=nameStrLen,
              )
          )
      else:
          print(
              iStr.format(
                  titleStr, typeStr, iouStr, areaRng, maxDets, mean_s
              )
          )
      return mean_s
  
file_path: sahi/sahi/scripts/coco_evaluation.py
imports: import itertools
  import json
  import warnings
  from collections import OrderedDict
  from pathlib import Path
  from typing import List, Union
  import fire
  import numpy
  from terminaltables import AsciiTable
label_desc: Use image node_id 1 for calling a global function with example usage: _cocoeval_summarize(cocoeval, ap, iouThr, catIdx, areaRng, maxDets, catName, nameStrLen) and returns: mean_s