class_docstr: `ImageNetv2 Dataset <https://arxiv.org/abs/1902.10811>`_ for studying the robustness of models trained on ImageNet dataset
  
  Args:
      opts: command-line arguments
class_docstr_tok: ["`","ImageNetv2","Dataset","<","https",":","\/\/arxiv.org\/abs\/1902.10811",">","`","_","for","studying","the","robustness","of","models","trained","on","ImageNet","dataset","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)
  
  Shapes:
      The output data dictionary contains three keys (samples, sample_id, and target). The values of these
      keys has the following shapes:
          data["samples"]: Shape is [Channels, Height, Width]
          data["sample_id"]: Shape is 1
          data["targets"]: Shape is 1
  
  Returns:
      A dictionary with `samples`, `sample_id` and `targets` as keys corresponding to input, index and label of
      a sample, respectively.
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",")","Shapes",":","The","output","data","dictionary","contains","three","keys","(","samples",",","sample_id",",","and","target",")",".","The","values","of","these","keys","has","the","following","shapes",":","data","[","``","samples","''","]",":","Shape","is","[","Channels",",","Height",",","Width","]","data","[","``","sample_id","''","]",":","Shape","is","1","data","[","``","targets","''","]",":","Shape","is","1","Returns",":","A","dictionary","with","`","samples","`",",","`","sample_id","`","and","`","targets","`","as","keys","corresponding","to","input",",","index","and","label","of","a","sample",",","respectively","."]
code: def __getitem__(self, sample_size_and_index: Tuple) -> Dict:
      """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)
  
      Shapes:
          The output data dictionary contains three keys (samples, sample_id, and target). The values of these
          keys has the following shapes:
              data["samples"]: Shape is [Channels, Height, Width]
              data["sample_id"]: Shape is 1
              data["targets"]: Shape is 1
  
      Returns:
          A dictionary with `samples`, `sample_id` and `targets` as keys corresponding to input, index and label of
          a sample, respectively.
      """
      crop_size_h, crop_size_w, img_index = sample_size_and_index
  
      # same for validation and evaluation
      transform_fn = self.get_augmentation_transforms(
          size=(crop_size_h, crop_size_w)
      )
  
      # infer target label from the file name
      # file names are organized as SPLIT_NAME-format-val/class_idx/*.jpg
      # Example: All images in this folder (imagenetv2-matched-frequency-format-val/0/*.jpg) belong to class 0
      img_path = str(self.file_names[img_index])
      target = int(self.file_names[img_index].parent.name)
  
      input_img = self.read_image_pil(img_path)
      if input_img is None:
          # Sometimes images are corrupt
          # Skip such images
          logger.log(
              "Img index {} is possibly corrupt.".format(img_index)
          )
          input_tensor = torch.zeros(
              size=(3, crop_size_h, crop_size_w), dtype=torch.float
          )
          target = -1
          data = {"image": input_tensor}
      else:
          data = {"image": input_img}
          data = transform_fn(data)
  
      data["samples"] = data["image"]
      data["targets"] = target
      data["sample_id"] = img_index
  
      return data
  
file_path: ml-cvnets/data/datasets/classification/imagenet_v2.py
imports: import argparse
  import tarfile
  from pathlib import Path
  from typing import Dict, Tuple
  import torch
  from data.datasets import DATASET_REGISTRY
  from data.datasets.dataset_base import BaseImageDataset
  from data.transforms import image_pil
  from data.transforms.common import Compose
  from utils import logger
  from utils.download_utils import get_local_path
label_desc: Use image node_id 4 for calling the Imagenetv2Dataset obj's underlying member method code with example usage: obj.__getitem__(sample_size_and_index) and returns: data