class_docstr: Dataset class for the MS COCO Object Detection using Mask RCNN .
  
  Args:
      opts: Command-line arguments
class_docstr_tok: ["Dataset","class","for","the","MS","COCO","Object","Detection","using","Mask","RCNN",".","Args",":","opts",":","Command-line","arguments"]
docstr: Returns the sample corresponding to the input sample index. Returned sample is transformed
  into the size specified by the input.
  
  Args:
      sample_size_and_index: Tuple of the form (crop_size_h, crop_size_w, sample_index)
  
  Returns:
      A dictionary with `samples` and `targets` as keys corresponding to input and labels of
      a sample, respectively.
  
  Shapes:
      The shape of values in output dictionary, output_data, are as follows:
  
      output_data["samples"]["image"]: Shape is [Channels, Height, Width]
      output_data["samples"]["label]["labels"]: Shape is [Num of boxes]
      output_data["samples"]["label"]["boxes"]: Shape is [Num of boxes, 4]
      output_data["samples"]["label"]["masks"]: Shape is [Num of boxes, Height, Width]
      output_data["targets"]["image_id"]: Shape is [1]
      output_data["targets"]["image_width"]: Shape is [1]
      output_data["targets"]["image_height"]: Shape is [1]
docstr_tok: ["Returns","the","sample","corresponding","to","the","input","sample","index",".","Returned","sample","is","transformed","into","the","size","specified","by","the","input",".","Args",":","sample_size_and_index",":","Tuple","of","the","form","(","crop_size_h",",","crop_size_w",",","sample_index",")","Returns",":","A","dictionary","with","`","samples","`","and","`","targets","`","as","keys","corresponding","to","input","and","labels","of","a","sample",",","respectively",".","Shapes",":","The","shape","of","values","in","output","dictionary",",","output_data",",","are","as","follows",":","output_data","[","``","samples","''","]","[","``","image","''","]",":","Shape","is","[","Channels",",","Height",",","Width","]","output_data","[","``","samples","''","]","[","``","label","]","[","``","labels","''","]",":","Shape","is","[","Num","of","boxes","]","output_data","[","``","samples","''","]","[","``","label","''","]","[","``","boxes","''","]",":","Shape","is","[","Num","of","boxes",",","4","]","output_data","[","``","samples","''","]","[","``","label","''","]","[","``","masks","''","]",":","Shape","is","[","Num","of","boxes",",","Height",",","Width","]","output_data","[","``","targets","''","]","[","``","image_id","''","]",":","Shape","is","[","1","]","output_data","[","``","targets","''","]","[","``","image_width","''","]",":","Shape","is","[","1","]","output_data","[","``","targets","''","]","[","``","image_height","''","]",":","Shape","is","[","1","]"]
code: def __getitem__(
      self, sample_size_and_index: Tuple[int, int, int], *args, **kwargs
  ) -> Mapping[str, Union[Tensor, Mapping[str, Tensor]]]:
      """Returns the sample corresponding to the input sample index. Returned sample is transformed
      into the size specified by the input.
  
      Args:
          sample_size_and_index: Tuple of the form (crop_size_h, crop_size_w, sample_index)
  
      Returns:
          A dictionary with `samples` and `targets` as keys corresponding to input and labels of
          a sample, respectively.
  
      Shapes:
          The shape of values in output dictionary, output_data, are as follows:
  
          output_data["samples"]["image"]: Shape is [Channels, Height, Width]
          output_data["samples"]["label]["labels"]: Shape is [Num of boxes]
          output_data["samples"]["label"]["boxes"]: Shape is [Num of boxes, 4]
          output_data["samples"]["label"]["masks"]: Shape is [Num of boxes, Height, Width]
          output_data["targets"]["image_id"]: Shape is [1]
          output_data["targets"]["image_width"]: Shape is [1]
          output_data["targets"]["image_height"]: Shape is [1]
      """
      crop_size_h, crop_size_w, img_index = sample_size_and_index
  
      transform_fn = self.get_augmentation_transforms(
          size=(crop_size_h, crop_size_w)
      )
  
      image_id = self.ids[img_index]
  
      image, img_name = self.get_image(image_id=image_id)
      im_width, im_height = image.size
  
      boxes, labels, mask = self.get_boxes_and_labels(
          image_id=image_id,
          image_width=im_width,
          image_height=im_height,
          include_masks=True,
      )
  
      data = {
          "image": image,
          "box_labels": labels,
          "box_coordinates": boxes,
          "mask": mask,
      }
  
      if transform_fn is not None:
          data = transform_fn(data)
  
      output_data = {
          "samples": {
              "image": data["image"],
              # PyTorch Mask RCNN implementation expect labels as an input. Because we do not want to change
              # the training infrastructure of CVNets library, we pass labels as part of image key and
              # handle it in the model.
              "label": {
                  "labels": data["box_labels"],
                  "boxes": data["box_coordinates"],
                  "masks": data["mask"],
              },
          },
          "targets": {
              "image_id": torch.tensor(image_id),
              "image_width": torch.tensor(im_width),
              "image_height": torch.tensor(im_height),
          },
      }
  
      return output_data
  
file_path: ml-cvnets/data/datasets/detection/coco_mask_rcnn.py
imports: import argparse
  from typing import List, Mapping, Tuple, Union
  import torch
  from torch import Tensor
  from data.collate_fns import COLLATE_FN_REGISTRY
  from data.datasets import DATASET_REGISTRY
  from data.datasets.detection.coco_base import COCODetection
  from data.transforms import image_pil
  from data.transforms.common import Compose
label_desc: Use image node_id 5 for calling the COCODetectionMaskRCNN obj's underlying member method code with example usage: obj.__getitem__(sample_size_and_index) and returns: output_data