code: def box_iou(
      boxes1: NdarrayOrTensor, boxes2: NdarrayOrTensor
  ) -> NdarrayOrTensor:
      """
      Compute the intersection over union (IoU) of two set of boxes.
  
      Args:
          boxes1: bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode``
          boxes2: bounding boxes, Mx4 or Mx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode``
  
      Returns:
          IoU, with size of (N,M) and same data type as ``boxes1``
  
      """
  
      if not isinstance(boxes1, type(boxes2)):
          warnings.warn(
              f"boxes1 is {type(boxes1)}, while boxes2 is {type(boxes2)}. The result will be {type(boxes1)}."
          )
  
      # convert numpy to tensor if needed
      boxes1_t, *_ = convert_data_type(boxes1, torch.Tensor)
      boxes2_t, *_ = convert_data_type(boxes2, torch.Tensor)
  
      # we do computation with compute_dtype to avoid overflow
      box_dtype = boxes1_t.dtype
  
      inter, union = _box_inter_union(
          boxes1_t, boxes2_t, compute_dtype=COMPUTE_DTYPE
      )
  
      # compute IoU and convert back to original box_dtype
      iou_t = inter / (union + torch.finfo(COMPUTE_DTYPE).eps)  # (N,M)
      iou_t = iou_t.to(dtype=box_dtype)
  
      # check if NaN or Inf
      if torch.isnan(iou_t).any() or torch.isinf(iou_t).any():
          raise ValueError("Box IoU is NaN or Inf.")
  
      # convert tensor back to numpy if needed
      iou, *_ = convert_to_dst_type(src=iou_t, dst=boxes1)
      return iou
  
imports: from __future__ import annotations
  import inspect
  import warnings
  from abc import ABC, abstractmethod
  from collections.abc import Callable, Sequence
  from copy import deepcopy
  import numpy
  import torch
  from monai.config.type_definitions import NdarrayOrTensor, NdarrayTensor
  from monai.utils import look_up_option
  from monai.utils.enums import BoxModeName
  from monai.utils.type_conversion import convert_data_type, convert_to_dst_type
label_desc: Use image node_id 12 for calling a global function with example usage: box_iou(boxes1, boxes2) and returns: iou