class_docstr: This class stores the segmentation masks for all objects in one image, in
  the form of bitmaps.
  
  Attributes:
      tensor: bool Tensor of N,H,W, representing N instances in the image.
class_docstr_tok: ["This","class","stores","the","segmentation","masks","for","all","objects","in","one","image",",","in","the","form","of","bitmaps",".","Attributes",":","tensor",":","bool","Tensor","of","N",",","H",",","W",",","representing","N","instances","in","the","image","."]
docstr: Args:
      tensor: bool Tensor of N,H,W, representing N instances in the image.
docstr_tok: ["Args",":","tensor",":","bool","Tensor","of","N",",","H",",","W",",","representing","N","instances","in","the","image","."]
code: def __init__(self, tensor: Union[torch.Tensor, np.ndarray]):
      """
      Args:
          tensor: bool Tensor of N,H,W, representing N instances in the image.
      """
      if isinstance(tensor, torch.Tensor):
          tensor = tensor.to(torch.bool)
      else:
          tensor = torch.as_tensor(
              tensor, dtype=torch.bool, device=torch.device("cpu")
          )
      assert tensor.dim() == 3, tensor.size()
      self.image_size = tensor.shape[1:]
      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 BitMasks object  with example: obj = BitMasks(tensor)