code: def _activitynet_evaluation_setup(
      gts,
      preds,
      id_keys,
      iou_key,
      config,
  ):
      classwise = config.classwise
  
      # 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 segments in cats.values():
          gts = segments["gts"]
          preds = segments["preds"]
  
          # Highest confidence predictions first
          preds = sorted(
              preds, key=lambda p: p.confidence or -1, reverse=True
          )
  
          segments["preds"] = preds
  
          # Compute ``num_preds x num_gts`` IoUs
          ious = foui.compute_segment_ious(preds, gts)
  
          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
  
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: _activitynet_evaluation_setup(gts, preds, id_keys, iou_key, config) and returns: cats,  pred_ious