code: def mask_iou(masks_1: np.ndarray, masks_2: np.ndarray) -> np.ndarray:
      """Computes the IoU between two sets of boolean masks
  
      Args:
      ----
          masks_1: boolean masks of shape (N, H, W)
          masks_2: boolean masks of shape (M, H, W)
  
      Returns:
      -------
          the IoU matrix of shape (N, M)
      """
      if masks_1.shape[1:] != masks_2.shape[1:]:
          raise AssertionError(
              "both boolean masks should have the same spatial shape"
          )
  
      iou_mat: np.ndarray = np.zeros(
          (masks_1.shape[0], masks_2.shape[0]), dtype=np.float32
      )
  
      if masks_1.shape[0] > 0 and masks_2.shape[0] > 0:
          axes = tuple(range(2, masks_1.ndim + 1))
          intersection = np.logical_and(
              masks_1[:, None, ...], masks_2[None, ...]
          ).sum(axis=axes)
          union = np.logical_or(
              masks_1[:, None, ...], masks_2[None, ...]
          ).sum(axis=axes)
          iou_mat = intersection / union
  
      return iou_mat
  
imports: from typing import Dict, List, Optional, Tuple
  import cv2
  import numpy
  from scipy.optimize import linear_sum_assignment
  from unidecode import unidecode
label_desc: Use image node_id 4 for calling a global function with example usage: mask_iou(masks_1, masks_2) and returns: iou_mat