class_docstr: Represent masks by N smaller masks defined in some ROIs. Once ROI boxes are given,
  full-image bitmask can be obtained by "pasting" the mask on the region defined
  by the corresponding ROI box.
class_docstr_tok: ["Represent","masks","by","N","smaller","masks","defined","in","some","ROIs",".","Once","ROI","boxes","are","given",",","full-image","bitmask","can","be","obtained","by","``","pasting","''","the","mask","on","the","region","defined","by","the","corresponding","ROI","box","."]
docstr: Args:
      tensor: (N, M, M) mask tensor that defines the mask within each ROI.
docstr_tok: ["Args",":","tensor",":","(","N",",","M",",","M",")","mask","tensor","that","defines","the","mask","within","each","ROI","."]
code: def __init__(self, tensor: torch.Tensor):
      """
      Args:
          tensor: (N, M, M) mask tensor that defines the mask within each ROI.
      """
      if tensor.dim() != 3:
          raise ValueError("ROIMasks must take a masks of 3 dimension.")
      self.tensor = tensor
  
imports: import copy
  import itertools
  import numpy
  from typing import Any, Iterator, List, Union
  import pycocotools.mask
  import torch
  from torch import device
  from detectron2.layers.roi_align import ROIAlign
  from detectron2.utils.memory import retry_if_cuda_oom
  from .boxes import Boxes
label_desc: Use image node_id 1 to create a new ROIMasks object  with example: obj = ROIMasks(tensor)