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: Returns:
      ROIMasks: Create a new :class:`ROIMasks` by indexing.
  
  The following usage are allowed:
  
  1. `new_masks = masks[2:10]`: return a slice of masks.
  2. `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",":","ROIMasks",":","Create","a","new",":","class",":","`","ROIMasks","`","by","indexing",".","The","following","usage","are","allowed",":","1",".","`","new_masks","=","masks","[","2:10","]","`",":","return","a","slice","of","masks",".","2",".","`","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) -> "ROIMasks":
      """
      Returns:
          ROIMasks: Create a new :class:`ROIMasks` by indexing.
  
      The following usage are allowed:
  
      1. `new_masks = masks[2:10]`: return a slice of masks.
      2. `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.
      """
      t = self.tensor[item]
      if t.dim() != 3:
          raise ValueError(
              f"Indexing on ROIMasks with {item} returns a tensor with shape {t.shape}!"
          )
      return ROIMasks(t)
  
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 5 for calling the ROIMasks obj's underlying member method code with example usage: obj.__getitem__(item) and returns: ROIMasks