code: def pairwise_iou(boxes1: Boxes, boxes2: Boxes) -> torch.Tensor:
      """
      Given two lists of boxes of size N and M, compute the IoU
      (intersection over union) between **all** N x M pairs of boxes.
      The box order must be (xmin, ymin, xmax, ymax).
  
      Args:
          boxes1,boxes2 (Boxes): two `Boxes`. Contains N & M boxes, respectively.
  
      Returns:
          Tensor: IoU, sized [N,M].
      """
      area1 = boxes1.area()  # [N]
      area2 = boxes2.area()  # [M]
      inter = pairwise_intersection(boxes1, boxes2)
  
      # handle empty boxes
      iou = torch.where(
          inter > 0,
          inter / (area1[:, None] + area2 - inter),
          torch.zeros(1, dtype=inter.dtype, device=inter.device),
      )
      return iou
  
imports: import math
  import numpy
  from enum import IntEnum, unique
  from typing import List, Tuple, Union
  import torch
  from torch import device
label_desc: Use image node_id 2 for calling a global function with example usage: pairwise_iou(boxes1, boxes2) and returns: iou