class_docstr: Image Classification Dataset.
  
  
  This base class can be used to represent any image classification dataset which is stored in a way that meets the
  expectations of `torchvision.datasets.ImageFolder`. New image classification datasets can be derived from this
  similar to ImageNetDataset (imagenet.py) or Places365Dataset (places365.py) and overwrite the data transformations
  as needed. This dataset also supports sampling a random subset of the training set to be used for training. The
  subset size is determined by the arguments `dataset.num_samples_per_category` and `dataset.percentage_of_samples`
  in the input `opts`. Only one of these two should be specified. When `dataset.percentage_of_samples` is specified,
  data is sampled from all classes according to this percentage such that the distribution of classes does not change.
   The randomness in sampling is controlled by the `dataset.sample_selection_random_seed` in the input `opts`.
  
  Args:
      opts: An argparse.Namespace instance.
class_docstr_tok: ["Image","Classification","Dataset",".","This","base","class","can","be","used","to","represent","any","image","classification","dataset","which","is","stored","in","a","way","that","meets","the","expectations","of","`","torchvision.datasets.ImageFolder","`",".","New","image","classification","datasets","can","be","derived","from","this","similar","to","ImageNetDataset","(","imagenet.py",")","or","Places365Dataset","(","places365.py",")","and","overwrite","the","data","transformations","as","needed",".","This","dataset","also","supports","sampling","a","random","subset","of","the","training","set","to","be","used","for","training",".","The","subset","size","is","determined","by","the","arguments","`","dataset.num_samples_per_category","`","and","`","dataset.percentage_of_samples","`","in","the","input","`","opts","`",".","Only","one","of","these","two","should","be","specified",".","When","`","dataset.percentage_of_samples","`","is","specified",",","data","is","sampled","from","all","classes","according","to","this","percentage","such","that","the","distribution","of","classes","does","not","change",".","The","randomness","in","sampling","is","controlled","by","the","`","dataset.sample_selection_random_seed","`","in","the","input","`","opts","`",".","Args",":","opts",":","An","argparse.Namespace","instance","."]
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`, `sample_id` and `targets` as keys corresponding to input, index and label of
      a sample, respectively.
  
  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
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","`",",","`","sample_id","`","and","`","targets","`","as","keys","corresponding","to","input",",","index","and","label","of","a","sample",",","respectively",".","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"]
code: def __getitem__(
      self, sample_size_and_index: Tuple[int, int, int]
  ) -> Dict[str, Any]:
      """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`, `sample_id` and `targets` as keys corresponding to input, index and label of
          a sample, respectively.
  
      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
      """
      crop_size_h, crop_size_w, sample_index = sample_size_and_index
      transform_fn = self.get_augmentation_transforms(
          size=(crop_size_h, crop_size_w)
      )
  
      img_path, target = self.samples[sample_index]
      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(sample_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.pop("image")
      data["targets"] = target
      data["sample_id"] = sample_index
  
      return data
  
imports: import argparse
  from typing import Any, Dict, Tuple, Union
  import torch
  from torchvision.datasets import ImageFolder
  from data.datasets.dataset_base import BaseImageDataset
  from data.datasets.utils.common import select_samples_by_category
  from data.transforms import image_pil
  from data.transforms.common import Compose
  from utils import logger
  from utils.ddp_utils import is_master
label_desc: Use image node_id 5 for calling the BaseImageClassificationDataset obj's underlying member method code with example usage: obj.__getitem__(sample_size_and_index) and returns: data