code: def get_average_per_class_confusion_matrix(
      labels: List[Dict[str, Any]],
      predictions: List[np.ndarray],
      num_procs: int = 1,
      class_names: Optional[Dict[Any, Any]] = None,
  ) -> Dict[Union[int, str], Dict[str, float]]:
      """
      Compute a confusion matrix dictionary for each class containing the average number of True Positive, False Positive, and False Negative detections from the object detection model across a range of Intersection over Union thresholds.
  
      At each IoU threshold, the metrics are calculated as follows:
      - True Positive (TP): Instances where the model correctly identifies the class with IoU above the threshold.
      - False Positive (FP): Instances where the model predicts the class, but IoU is below the threshold.
      - False Negative (FN): Instances where the ground truth class is not predicted by the model.
  
      The average confusion matrix provides insights into the model strengths and potential biases.
  
      Note:  lower TP at certain IoU thresholds does not necessarily imply that everything else is FP, instead it indicates that, at those specific IoU thresholds, the model is not performing as well in terms of correctly identifying class instances. The other metrics (FP and FN) provide additional information about the model's behavior.
  
      Note: Since we average over many IoU thresholds, 'TP', 'FP', and 'FN' may contain float values representing the average across these thresholds.
  
      Parameters
      ----------
      labels:
          A list of ``N`` dictionaries such that ``labels[i]`` contains the given labels for the `i`-th image.
          Refer to documentation for this argument in :py:func:`object_detection.filter.find_label_issues <cleanlab.object_detection.filter.find_label_issues>` for further details.
  
      predictions:
          A list of ``N`` ``np.ndarray`` such that ``predictions[i]`` corresponds to the model predictions for the `i`-th image.
          Refer to documentation for this argument in :py:func:`object_detection.filter.find_label_issues <cleanlab.object_detection.filter.find_label_issues>` for further details.
  
      num_procs:
          Number of processes for parallelization. Default is 1.
  
      class_names:
          Optional dictionary mapping one-hot-encoded class labels back to their original class names in the format ``{"integer-label": "original-class-name"}``
  
  
      Returns
      -------
      avg_metrics: dict
          A distionary containing the average confusion matrix.
  
          The default range of Intersection over Union thresholds is from 0.5 to 0.95 with a step size of 0.05.
      """
      iou_thrs = np.linspace(
          0.5,
          0.95,
          int(np.round((0.95 - 0.5) / 0.05)) + 1,
          endpoint=True,
      )
      num_classes = len(predictions[0])
      if class_names is None:
          class_names = {
              str(i): int(i) for i in list(range(num_classes))
          }
      class_names = _sort_dict_to_list(class_names)
      avg_metrics = {
          class_num: {"TP": 0.0, "FP": 0.0, "FN": 0.0}
          for class_num in class_names
      }
  
      for iou_threshold in iou_thrs:
          results_dict = _get_per_class_confusion_matrix_dict_(
              labels, predictions, iou_threshold, num_procs
          )
  
          for class_num in results_dict:
              tp = results_dict[class_num]["TP"]
              fp = results_dict[class_num]["FP"]
              fn = results_dict[class_num]["FN"]
  
              avg_metrics[class_names[class_num]]["TP"] += tp
              avg_metrics[class_names[class_num]]["FP"] += fp
              avg_metrics[class_names[class_num]]["FN"] += fn
  
      num_thresholds = len(iou_thrs) * len(results_dict)
      for class_name in avg_metrics:
          avg_metrics[class_name]["TP"] /= num_thresholds
          avg_metrics[class_name]["FP"] /= num_thresholds
          avg_metrics[class_name]["FN"] /= num_thresholds
      return avg_metrics
  
imports: from multiprocessing import Pool
  from typing import Optional, Any, Dict, Tuple, Union, List, TYPE_CHECKING, TypeVar, DefaultDict
  import numpy
  import collections
  from cleanlab.internal.constants import MAX_CLASS_TO_SHOW, ALPHA, EPSILON, TINY_VALUE
  from cleanlab.object_detection.filter import _filter_by_class, _calculate_true_positives_false_positives
  from cleanlab.object_detection.rank import _get_valid_inputs_for_compute_scores, _separate_prediction, _separate_label, _get_prediction_type
  from cleanlab.internal.object_detection_utils import bbox_xyxy_to_xywh
label_desc: Use image node_id 10 for calling a global function with example usage: get_average_per_class_confusion_matrix(labels, predictions, num_procs, class_names) and returns: avg_metrics