code: def box_iou(boxes1, boxes2):
      """
      Return intersection-over-union (Jaccard index) of boxes.
  
      Both sets of boxes are expected to be in (x1, y1, x2, y2) format.
  
      Arguments:
          boxes1 (Tensor[N, 4])
          boxes2 (Tensor[M, 4])
  
      Returns:
          iou (Tensor[N, M]): the NxM matrix containing the pairwise
              IoU values for every element in boxes1 and boxes2
      """
      area1 = box_area(boxes1)
      area2 = box_area(boxes2)
  
      #  When the shapes do not match,
      #  the shape of the returned output tensor follows the broadcasting rules
      lt = torch.max(
          boxes1[:, None, :2], boxes2[:, :2]
      )  # left-top [N,M,2]
      rb = torch.min(
          boxes1[:, None, 2:], boxes2[:, 2:]
      )  # right-bottom [N,M,2]
  
      wh = (rb - lt).clamp(min=0)  # [N,M,2]
      inter = wh[:, :, 0] * wh[:, :, 1]  # [N,M]
  
      iou = inter / (area1[:, None] + area2 - inter)
      return iou
  
file_path: deep-learning-for-image-processing/pytorch_object_detection/retinaNet/network_files/boxes.py
imports: import torch
  from typing import Tuple
  from torch import Tensor
  import torchvision
label_desc: Use image node_id 6 for calling a global function with example usage: box_iou(boxes1, boxes2) and returns: iou