code: def rbox_to_mask(
      boxes: np.ndarray, shape: Tuple[int, int]
  ) -> np.ndarray:
      """Converts rotated bounding boxes to boolean masks
  
      Args:
      ----
          boxes: rotated bounding boxes of shape (N, 4, 2)
          shape: spatial shapes of the output masks
  
      Returns:
      -------
          the boolean masks of shape (N, H, W)
      """
      masks: np.ndarray = np.zeros(
          (boxes.shape[0], *shape), dtype=np.uint8
      )
  
      if boxes.shape[0] > 0:
          # Get absolute coordinates
          if not np.issubdtype(boxes.dtype, np.integer):
              abs_boxes = boxes.copy()
              abs_boxes[:, :, 0] = abs_boxes[:, :, 0] * shape[1]
              abs_boxes[:, :, 1] = abs_boxes[:, :, 1] * shape[0]
              abs_boxes = abs_boxes.round().astype(int)
          else:
              abs_boxes = boxes
              abs_boxes[:, 2:] = abs_boxes[:, 2:] + 1
  
          # TODO: optimize slicing to improve vectorization
          for idx, _box in enumerate(abs_boxes):
              cv2.fillPoly(masks[idx], [_box - 1], 1.0)  # type: ignore[call-overload]
      return masks.astype(bool)
  
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 7 for calling a global function with example usage: rbox_to_mask(boxes, shape) and returns: masks