class_docstr: Calculate the confusion matrix of the model on the given dataset.
  
  For object detection, each detected bounding box calculates the IoU for each label and then that label class is
  used for the confusion matrix. detected bounding boxes that don't match a label has their own class and same
  for labels without detected bounding boxes.
  
  Parameters
  ----------
  categories_to_display (int, default 10):
      Maximum number of categories to display
  confidence_threshold (float, default 0.3):
      Threshold to consider bounding box as detected.
  iou_threshold (float, default 0.5):
      Threshold to consider detected bounding box as labeled bounding box.
  normalized (bool, default True):
      boolean that determines whether to normalize the true values of the matrix.
  {additional_check_init_params:2*indent}
class_docstr_tok: ["Calculate","the","confusion","matrix","of","the","model","on","the","given","dataset",".","For","object","detection",",","each","detected","bounding","box","calculates","the","IoU","for","each","label","and","then","that","label","class","is","used","for","the","confusion","matrix",".","detected","bounding","boxes","that","do","n't","match","a","label","has","their","own","class","and","same","for","labels","without","detected","bounding","boxes",".","Parameters","--","--","--","--","--","categories_to_display","(","int",",","default","10",")",":","Maximum","number","of","categories","to","display","confidence_threshold","(","float",",","default","0.3",")",":","Threshold","to","consider","bounding","box","as","detected",".","iou_threshold","(","float",",","default","0.5",")",":","Threshold","to","consider","detected","bounding","box","as","labeled","bounding","box",".","normalized","(","bool",",","default","True",")",":","boolean","that","determines","whether","to","normalize","the","true","values","of","the","matrix",".","{","additional_check_init_params:2","*","indent","}"]
docstr: Update the confusion matrix by batch for object detection task.
docstr_tok: ["Update","the","confusion","matrix","by","batch","for","object","detection","task","."]
code: def update_object_detection(self, predictions, labels):
      """Update the confusion matrix by batch for object detection task."""
      for image_detections, image_labels in zip(predictions, labels):
          detections_passed_threshold = [
              detection
              for detection in image_detections
              if detection[4] > self.confidence_threshold
          ]
  
          if len(detections_passed_threshold) == 0:
              # detections are empty, update matrix for labels
              for label in image_labels:
                  label_class = int(label[0])
                  self.matrix[label_class][-1] += 1
              continue
  
          list_of_ious = (
              (
                  label_index,
                  detected_index,
                  jaccard_iou(detected, label),
              )
              for label_index, label in enumerate(image_labels)
              for detected_index, detected in enumerate(
                  detections_passed_threshold
              )
          )
          matches = np.array(
              [
                  [label_index, detected_index, ious]
                  for label_index, detected_index, ious in list_of_ious
                  if ious > self.iou_threshold
              ]
          )
  
          # remove duplicate matches
          if len(matches) > 0:
              # sort by ious, in descend order
              matches = matches[matches[:, 2].argsort()[::-1]]
              # leave matches with unique prediction and the highest ious
              matches = matches[
                  np.unique(matches[:, 1], return_index=True)[1]
              ]
              # sort by ious, in descend order
              matches = matches[matches[:, 2].argsort()[::-1]]
              # leave matches with unique label and the highest ious
              matches = matches[
                  np.unique(matches[:, 0], return_index=True)[1]
              ]
  
          n_of_matches = len(matches)
  
          for label_index, label in enumerate(image_labels):
              label_class = int(label[0])
              if (
                  n_of_matches > 0
                  and (matches[:, 0] == label_index).any()
              ):
                  detection_index = int(
                      matches[matches[:, 0] == label_index, 1][0]
                  )
                  detected_class = int(
                      image_detections[detection_index][5]
                  )
                  self.matrix[label_class][detected_class] += 1
              else:
                  self.matrix[label_class][-1] += 1
  
          for detection_index, detection in enumerate(
              detections_passed_threshold
          ):
              if (
                  n_of_matches > 0
                  and not (matches[:, 1] == detection_index).any()
              ):
                  detected_class = int(detection[5])
                  self.matrix[-1][detected_class] += 1
  
imports: import typing
  from collections import defaultdict
  from queue import PriorityQueue
  import numpy
  import pandas
  from deepchecks.core import CheckResult, DatasetKind
  from deepchecks.utils.abstracts.confusion_matrix_abstract import create_confusion_matrix_figure
  from deepchecks.vision._shared_docs import docstrings
  from deepchecks.vision.base_checks import SingleDatasetCheck
  from deepchecks.vision.context import Context
  from deepchecks.vision.metrics_utils.iou_utils import jaccard_iou
  from deepchecks.vision.vision_data import TaskType
  from deepchecks.vision.vision_data.batch_wrapper import BatchWrapper
label_desc: Use image node_id 5 for calling the ConfusionMatrixReport obj's underlying member method code with example usage: obj.update_object_detection(predictions, labels) without return types