code: def _calculate_true_positives_false_positives(
      pred_bboxes: np.ndarray,
      lab_bboxes: np.ndarray,
      iou_threshold: Optional[float] = 0.5,
      return_false_negative: bool = False,
  ) -> Union[
      Tuple[np.ndarray, np.ndarray],
      Tuple[np.ndarray, np.ndarray, np.ndarray],
  ]:
      """Calculates true positives (TP) and false positives (FP) for object detection tasks.
      It takes predicted bounding boxes, ground truth bounding boxes, and an optional Intersection over Union (IoU) threshold as inputs.
      If return_false_negative is True, it returns an array of False negatives as well.
      """
      num_preds = pred_bboxes.shape[0]
      num_labels = lab_bboxes.shape[0]
      num_scales = 1
      true_positives = np.zeros(
          (num_scales, num_preds), dtype=np.float32
      )
      false_positives = np.zeros(
          (num_scales, num_preds), dtype=np.float32
      )
  
      if lab_bboxes.shape[0] == 0:
          false_positives[...] = 1
          if return_false_negative:
              return (
                  true_positives,
                  false_positives,
                  np.array([], dtype=np.float32),
              )
          else:
              return true_positives, false_positives
      ious = _get_overlap_matrix(pred_bboxes, lab_bboxes)
      ious_max = ious.max(axis=1)
      ious_argmax = ious.argmax(axis=1)
      sorted_indices = np.argsort(-pred_bboxes[:, -1])
      is_covered = np.zeros(num_labels, dtype=bool)
      for index in sorted_indices:
          if ious_max[index] >= iou_threshold:
              matching_label = ious_argmax[index]
              if not is_covered[matching_label]:
                  is_covered[matching_label] = True
                  true_positives[0, index] = 1
              else:
                  false_positives[0, index] = 1
          else:
              false_positives[0, index] = 1
      if return_false_negative:
          false_negatives = np.zeros(
              (num_scales, num_labels), dtype=np.float32
          )
          for label_index in range(num_labels):
              if not is_covered[label_index]:
                  false_negatives[0, label_index] = 1
          return true_positives, false_positives, false_negatives
      return true_positives, false_positives
  
file_path: cleanlab/cleanlab/object_detection/filter.py
imports: from collections import defaultdict
  from multiprocessing import Pool
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  from cleanlab.internal.constants import ALPHA, HIGH_PROBABILITY_THRESHOLD, LOW_PROBABILITY_THRESHOLD, OVERLOOKED_THRESHOLD_FACTOR, BADLOC_THRESHOLD_FACTOR, SWAP_THRESHOLD_FACTOR, AP_SCALE_FACTOR
  from cleanlab.internal.object_detection_utils import assert_valid_inputs
  from cleanlab.object_detection.rank import _get_valid_inputs_for_compute_scores, _separate_label, _separate_prediction, compute_badloc_box_scores, compute_overlooked_box_scores, compute_swap_box_scores, get_label_quality_scores, issues_from_scores, _get_overlap_matrix
label_desc: Use image node_id 8 for calling a global function with example usage: _calculate_true_positives_false_positives(pred_bboxes, lab_bboxes, iou_threshold, return_false_negative) and returns: true_positives,  false_positives, true_positives,  false_positives,  false_negatives, true_positives,  false_positives,  np, true_positives,  false_positives