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: Returns:
      BitMasks: Create a new :class:`BitMasks` by indexing.
  
  The following usage are allowed:
  
  1. `new_masks = masks[3]`: return a `BitMasks` which contains only one mask.
  2. `new_masks = masks[2:10]`: return a slice of masks.
  3. `new_masks = masks[vector]`, where vector is a torch.BoolTensor
     with `length = len(masks)`. Nonzero elements in the vector will be selected.
  
  Note that the returned object might share storage with this object,
  subject to Pytorch's indexing semantics.
docstr_tok: ["Returns",":","BitMasks",":","Create","a","new",":","class",":","`","BitMasks","`","by","indexing",".","The","following","usage","are","allowed",":","1",".","`","new_masks","=","masks","[","3","]","`",":","return","a","`","BitMasks","`","which","contains","only","one","mask",".","2",".","`","new_masks","=","masks","[","2:10","]","`",":","return","a","slice","of","masks",".","3",".","`","new_masks","=","masks","[","vector","]","`",",","where","vector","is","a","torch.BoolTensor","with","`","length","=","len","(","masks",")","`",".","Nonzero","elements","in","the","vector","will","be","selected",".","Note","that","the","returned","object","might","share","storage","with","this","object",",","subject","to","Pytorch","'s","indexing","semantics","."]
code: def __getitem__(
      self, item: Union[int, slice, torch.BoolTensor]
  ) -> "BitMasks":
      """
      Returns:
          BitMasks: Create a new :class:`BitMasks` by indexing.
  
      The following usage are allowed:
  
      1. `new_masks = masks[3]`: return a `BitMasks` which contains only one mask.
      2. `new_masks = masks[2:10]`: return a slice of masks.
      3. `new_masks = masks[vector]`, where vector is a torch.BoolTensor
         with `length = len(masks)`. Nonzero elements in the vector will be selected.
  
      Note that the returned object might share storage with this object,
      subject to Pytorch's indexing semantics.
      """
      if isinstance(item, int):
          return BitMasks(self.tensor[item].unsqueeze(0))
      m = self.tensor[item]
      assert (
          m.dim() == 3
      ), "Indexing on BitMasks with {} returns a tensor with shape {}!".format(
          item, m.shape
      )
      return BitMasks(m)
  
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 4 for calling the BitMasks obj's underlying member method code with example usage: obj.__getitem__(item) and returns: BitMasks, BitMasks