code: def per_sample_mean_iou(
      predictions: np.ndarray, labels: np.ndarray
  ) -> List[float]:
      """Calculate mean iou for a single sample."""
      mean_ious = []
      for detected, ground_truth in zip(predictions, labels):
          if len(ground_truth) == 0:
              if len(detected) == 0:
                  mean_ious.append(1)
              else:
                  mean_ious.append(0)
              continue
          elif len(detected) == 0:
              mean_ious.append(0)
              continue
  
          ious = compute_bounding_box_class_ious(detected, ground_truth)
          count = 0
          sum_iou = 0
  
          for _, cls_ious in ious.items():
              # Find best fit for each detection
              for detection in cls_ious:
                  sum_iou += max(detection, default=0)
                  count += 1
  
          if count:
              mean_ious.append(sum_iou / count)
          else:
              mean_ious.append(0)
  
      return mean_ious
  
file_path: deepchecks/deepchecks/vision/metrics_utils/iou_utils.py
imports: from collections import defaultdict
  from typing import List
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: per_sample_mean_iou(predictions, labels) and returns: mean_ious