code: def _coco_evaluation_setup(
      gts, preds, id_keys, iou_key, config, max_preds=None
  ):
      iscrowd = lambda l: bool(
          l.get_attribute_value(config.iscrowd, False)
      )
      classwise = config.classwise
  
      iou_kwargs = dict(iscrowd=iscrowd, error_level=config.error_level)
  
      if config.use_masks:
          iou_kwargs.update(use_masks=True, tolerance=config.tolerance)
  
      if config.use_boxes:
          iou_kwargs.update(use_boxes=True)
  
      # Organize ground truth and predictions by category
  
      cats = defaultdict(lambda: defaultdict(list))
  
      if gts is not None:
          for obj in gts[gts._LABEL_LIST_FIELD]:
              obj[iou_key] = _NO_MATCH_IOU
              for id_key in id_keys:
                  obj[id_key] = _NO_MATCH_ID
  
              label = obj.label if classwise else "all"
              cats[label]["gts"].append(obj)
  
      if preds is not None:
          for obj in preds[preds._LABEL_LIST_FIELD]:
              obj[iou_key] = _NO_MATCH_IOU
              for id_key in id_keys:
                  obj[id_key] = _NO_MATCH_ID
  
              label = obj.label if classwise else "all"
              cats[label]["preds"].append(obj)
  
      # Compute IoUs within each category
      pred_ious = {}
      for objects in cats.values():
          gts = objects["gts"]
          preds = objects["preds"]
  
          # Highest confidence predictions first
          preds = sorted(
              preds, key=lambda p: p.confidence or -1, reverse=True
          )
  
          if max_preds is not None:
              preds = preds[:max_preds]
  
          objects["preds"] = preds
  
          # Sort ground truth so crowds are last
          gts = sorted(gts, key=iscrowd)
  
          # Compute ``num_preds x num_gts`` IoUs
          ious = foui.compute_ious(preds, gts, **iou_kwargs)
  
          gt_ids = [g.id for g in gts]
          for pred, gt_ious in zip(preds, ious):
              pred_ious[pred.id] = list(zip(gt_ids, gt_ious))
  
      return cats, pred_ious, iscrowd
  
imports: import logging
  from collections import defaultdict
  import numpy
  import eta.core.utils
  import fiftyone.core.plots
  import fiftyone.utils.iou
  from .detection import DetectionEvaluation, DetectionEvaluationConfig, DetectionResults
label_desc: Use image node_id 3 for calling a global function with example usage: _coco_evaluation_setup(gts, preds, id_keys, iou_key, config, max_preds) and returns: cats,  pred_ious,  iscrowd