code: def mask2bbox(masks):
      """Obtain tight bounding boxes of binary masks.
  
      Args:
          masks (Tensor): Binary mask of shape (n, h, w).
  
      Returns:
          Tensor: Bboxe with shape (n, 4) of \
              positive region in binary mask.
      """
      N = masks.shape[0]
      bboxes = masks.new_zeros((N, 4), dtype=torch.float32)
      x_any = torch.any(masks, dim=1)
      y_any = torch.any(masks, dim=2)
      for i in range(N):
          x = torch.where(x_any[i, :])[0]
          y = torch.where(y_any[i, :])[0]
          if len(x) > 0 and len(y) > 0:
              bboxes[i, :] = bboxes.new_tensor(
                  [x[0], y[0], x[-1] + 1, y[-1] + 1]
              )
  
      return bboxes
  
imports: import numpy
  import pycocotools.mask
  import torch
  from mmengine.utils import slice_list
label_desc: Use image node_id 3 for calling a global function with example usage: mask2bbox(masks) and returns: bboxes