code: def boxes_to_masks(
      boxes: list[Tensor], image_size: tuple[int, int]
  ) -> Tensor:
      """Convert bounding boxes to segmentations masks.
  
      Args:
          boxes (list[Tensor]): A list of length B where each element is a tensor of shape (N, 4) containing the bounding
              box coordinates of the regions of interest in xyxy format.
          image_size (tuple[int, int]): Image size of the output masks in (H, W) format.
  
      Returns:
          Tensor: Tensor of shape (B, H, W) in which each slice is a binary mask showing the pixels contained by a
              bounding box.
      """
      masks = torch.zeros((len(boxes),) + image_size).to(
          boxes[0].device
      )
      for im_idx, im_boxes in enumerate(boxes):
          for box in im_boxes:
              x_1, y_1, x_2, y_2 = box.int()
              masks[im_idx, y_1 : y_2 + 1, x_1 : x_2 + 1] = 1
      return masks
  
file_path: anomalib/src/anomalib/data/utils/boxes.py
imports: from __future__ import annotations
  import torch
  from torch import Tensor
  from anomalib.utils.cv import connected_components_cpu, connected_components_gpu
label_desc: Use image node_id 2 for calling a global function with example usage: boxes_to_masks(boxes, image_size) and returns: masks