code: def _get_pairwise_iou(
      pred: torch.Tensor,
      gt: torch.Tensor,
      device: str | torch.device = "cpu",
  ) -> tuple[torch.Tensor, list[torch.Tensor], list[torch.Tensor]]:
      pred_id_list = _get_id_list(pred)
      true_id_list = _get_id_list(gt)
  
      pairwise_iou = torch.zeros(
          [len(true_id_list) - 1, len(pred_id_list) - 1],
          dtype=torch.float,
          device=device,
      )
      true_masks: list[torch.Tensor] = []
      pred_masks: list[torch.Tensor] = []
  
      for t in true_id_list[1:]:
          t_mask = torch.as_tensor(gt == t, device=device).int()
          true_masks.append(t_mask)
  
      for p in pred_id_list[1:]:
          p_mask = torch.as_tensor(pred == p, device=device).int()
          pred_masks.append(p_mask)
  
      for true_id in range(1, len(true_id_list)):
          t_mask = true_masks[true_id - 1]
          pred_true_overlap = pred[t_mask > 0]
          pred_true_overlap_id = list(pred_true_overlap.unique())
          for pred_id in pred_true_overlap_id:
              if pred_id == 0:
                  continue
              p_mask = pred_masks[pred_id - 1]
              total = (t_mask + p_mask).sum()
              inter = (t_mask * p_mask).sum()
              iou = inter / (total - inter)
              pairwise_iou[true_id - 1, pred_id - 1] = iou
  
      return pairwise_iou, true_id_list, pred_id_list
  
file_path: MONAI/monai/metrics/panoptic_quality.py
imports: from __future__ import annotations
  from collections.abc import Sequence
  import torch
  from monai.metrics.metric import CumulativeIterationMetric
  from monai.metrics.utils import do_metric_reduction, remap_instance_id
  from monai.utils import MetricReduction, ensure_tuple, optional_import
label_desc: Use image node_id 3 for calling a global function with example usage: _get_pairwise_iou(pred, gt, device) and returns: pairwise_iou,  true_id_list,  pred_id_list