code: def _calculate_iou(
      pred_color: _Color,
      target_color: _Color,
      pred_areas: Dict[_Color, Tensor],
      target_areas: Dict[_Color, Tensor],
      intersection_areas: Dict[Tuple[_Color, _Color], Tensor],
      void_color: _Color,
  ) -> Tensor:
      """Helper function that calculates the IoU from precomputed areas of segments and their intersections.
  
      Args:
          pred_color: The `(category_id, instance_id)`, or "color", of a predicted segment that is being matched with a
              target segment.
          target_color: The `(category_id, instance_id)`, or "color", of a ground truth segment that is being matched
              with a predicted segment.
          pred_areas: Mapping from colors of the predicted segments to their extents.
          target_areas: Mapping from colors of the ground truth segments to their extents.
          intersection_areas: Mapping from tuples of `(pred_color, target_color)` to their extent.
          void_color: An additional color that is masked out during metrics calculation.
  
      Returns:
          The calculated IoU as a torch.Tensor containing a single scalar value.
  
      """
      if pred_color[0] != target_color[0]:
          raise ValueError(
              "Attempting to compute IoU on segments with different category ID: "
              f"pred {pred_color[0]}, target {target_color[0]}"
          )
      if pred_color == void_color:
          raise ValueError(
              "Attempting to compute IoU on a void segment."
          )
      intersection = intersection_areas[(pred_color, target_color)]
      pred_area = pred_areas[pred_color]
      target_area = target_areas[target_color]
      pred_void_area = intersection_areas.get(
          (pred_color, void_color), 0
      )
      void_target_area = intersection_areas.get(
          (void_color, target_color), 0
      )
      union = (
          pred_area
          - pred_void_area
          + target_area
          - void_target_area
          - intersection
      )
      return intersection / union
  
file_path: torchmetrics/src/torchmetrics/functional/detection/_panoptic_quality_common.py
imports: from typing import Collection, Dict, Iterator, List, Optional, Set, Tuple, cast
  import torch
  from torch import Tensor
  from torchmetrics.utilities import rank_zero_warn
label_desc: Use image node_id 10 for calling a global function with example usage: _calculate_iou(pred_color, target_color, pred_areas, target_areas, intersection_areas, void_color) and returns: unknown