code: def boxes_to_anomaly_maps(
      boxes: Tensor, scores: Tensor, image_size: tuple[int, int]
  ) -> Tensor:
      """Convert bounding box coordinates to anomaly heatmaps.
  
      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.
          scores (list[Tensor]): A list of length B where each element is a 1D tensor of length N containing the anomaly
              scores for each region of interest.
          image_size (tuple[int, int]): Image size of the output masks in (H, W) format.
  
      Returns:
          Tensor: Tensor of shape (B, H, W). The pixel locations within each bounding box are collectively assigned the
              anomaly score of the bounding box. In the case of overlapping bounding boxes, the highest score is used.
      """
      anomaly_maps = torch.zeros((len(boxes),) + image_size).to(
          boxes[0].device
      )
      for im_idx, (im_boxes, im_scores) in enumerate(
          zip(boxes, scores)
      ):
          im_map = torch.zeros((im_boxes.shape[0],) + image_size)
          for box_idx, (box, score) in enumerate(
              zip(im_boxes, im_scores)
          ):
              x_1, y_1, x_2, y_2 = box.int()
              im_map[box_idx, y_1 : y_2 + 1, x_1 : x_2 + 1] = score
              anomaly_maps[im_idx], _ = im_map.max(dim=0)
      return anomaly_maps
  
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 3 for calling a global function with example usage: boxes_to_anomaly_maps(boxes, scores, image_size) and returns: anomaly_maps