code: def _open_images_evaluation_setup(
      gts,
      preds,
      id_key,
      iou_key,
      config,
      pos_labs,
      neg_labs,
      max_preds=None,
  ):
      if pos_labs is None:
          relevant_labs = neg_labs
      elif neg_labs is None:
          relevant_labs = pos_labs
      else:
          relevant_labs = list(set(pos_labs + neg_labs))
  
      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]:
              if relevant_labs is None or obj.label in relevant_labs:
                  obj[iou_key] = _NO_MATCH_IOU
                  obj[id_key] = _NO_MATCH_ID
  
                  label = obj.label if classwise else "all"
                  cats[label]["gts"].append(obj)
  
                  if config.expand_gt_hierarchy and label != "all":
                      _expand_detection_hierarchy(
                          cats, obj, config, "gts"
                      )
  
      if preds is not None:
          for obj in preds[preds._LABEL_LIST_FIELD]:
              if relevant_labs is None or obj.label in relevant_labs:
                  obj[iou_key] = _NO_MATCH_IOU
                  obj[id_key] = _NO_MATCH_ID
  
                  label = obj.label if classwise else "all"
                  cats[label]["preds"].append(obj)
  
                  if config.expand_pred_hierarchy and label != "all":
                      _expand_detection_hierarchy(
                          cats, obj, config, "preds"
                      )
  
      # 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: from collections import defaultdict
  from copy import deepcopy
  import numpy
  import fiftyone.core.plots
  import fiftyone.utils.iou
  from .detection import DetectionEvaluation, DetectionEvaluationConfig, DetectionResults
label_desc: Use image node_id 4 for calling a global function with example usage: _open_images_evaluation_setup(gts, preds, id_key, iou_key, config, pos_labs, neg_labs, max_preds) and returns: cats,  pred_ious,  iscrowd