code: def masks_to_boxes(masks: torch.Tensor) -> torch.Tensor:
      """
      Compute the bounding boxes around the provided masks.
  
      Returns a [N, 4] tensor containing bounding boxes. The boxes are in ``(x1, y1, x2, y2)`` format with
      ``0 <= x1 < x2`` and ``0 <= y1 < y2``.
  
      Args:
          masks (Tensor[N, H, W]): masks to transform where N is the number of masks
              and (H, W) are the spatial dimensions.
  
      Returns:
          Tensor[N, 4]: bounding boxes
      """
      if not torch.jit.is_scripting() and not torch.jit.is_tracing():
          _log_api_usage_once(masks_to_boxes)
      if masks.numel() == 0:
          return torch.zeros(
              (0, 4), device=masks.device, dtype=torch.float
          )
  
      n = masks.shape[0]
  
      bounding_boxes = torch.zeros(
          (n, 4), device=masks.device, dtype=torch.float
      )
  
      for index, mask in enumerate(masks):
          y, x = torch.where(mask != 0)
  
          bounding_boxes[index, 0] = torch.min(x)
          bounding_boxes[index, 1] = torch.min(y)
          bounding_boxes[index, 2] = torch.max(x)
          bounding_boxes[index, 3] = torch.max(y)
  
      return bounding_boxes
  
imports: from typing import Tuple
  import torch
  import torchvision
  from torch import Tensor
  from torchvision.extension import _assert_has_ops
  from ..utils import _log_api_usage_once
  from ._box_convert import _box_cxcywh_to_xyxy, _box_xywh_to_xyxy, _box_xyxy_to_cxcywh, _box_xyxy_to_xywh
  from ._utils import _upcast
label_desc: Use image node_id 15 for calling a global function with example usage: masks_to_boxes(masks) and returns: bounding_boxes, torch