code: def convert_coco_poly_to_mask(segmentations, height, width):
      masks = []
      for polygons in segmentations:
          rles = coco_mask.frPyObjects(polygons, height, width)
          mask = coco_mask.decode(rles)
          if len(mask.shape) < 3:
              mask = mask[..., None]
          mask = torch.as_tensor(mask, dtype=torch.uint8)
          mask = mask.any(dim=2)
          masks.append(mask)
      if masks:
          masks = torch.stack(masks, dim=0)
      else:
          masks = torch.zeros((0, height, width), dtype=torch.uint8)
      return masks
  
file_path: vision/references/detection/coco_utils.py
imports: import os
  import torch
  import torch.utils.data
  import torchvision
  import transforms
  from pycocotools import mask
  from pycocotools.coco import COCO
label_desc: Use image node_id 1 for calling a global function with example usage: convert_coco_poly_to_mask(segmentations, height, width) and returns: masks