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 transformations applied to the input in training mode.
  
  Order of transformations: RandomResizedCrop, RandomHorizontalFlip, One of AutoAugment or RandAugment or
  TrivialAugmentWide, RandomErasing
  
  Batch-based augmentations such as Mixup and CutMix are implemented in trainer.
  
  Args:
      size: Size for resizing the input image. Expected to be an integer (width=height) or a tuple (height, width)
  
  Returns:
      An instance of `data.transforms.image_pil.BaseTransformation.`
docstr_tok: ["Returns","transformations","applied","to","the","input","in","training","mode",".","Order","of","transformations",":","RandomResizedCrop",",","RandomHorizontalFlip",",","One","of","AutoAugment","or","RandAugment","or","TrivialAugmentWide",",","RandomErasing","Batch-based","augmentations","such","as","Mixup","and","CutMix","are","implemented","in","trainer",".","Args",":","size",":","Size","for","resizing","the","input","image",".","Expected","to","be","an","integer","(","width=height",")","or","a","tuple","(","height",",","width",")","Returns",":","An","instance","of","`","data.transforms.image_pil.BaseTransformation.","`"]
code: def _training_transforms(
      self, size: Union[Tuple[int, int], int], *args, **kwargs
  ) -> image_pil.BaseTransformation:
      """
      Returns transformations applied to the input in training mode.
  
      Order of transformations: RandomResizedCrop, RandomHorizontalFlip, One of AutoAugment or RandAugment or
      TrivialAugmentWide, RandomErasing
  
      Batch-based augmentations such as Mixup and CutMix are implemented in trainer.
  
      Args:
          size: Size for resizing the input image. Expected to be an integer (width=height) or a tuple (height, width)
  
      Returns:
          An instance of `data.transforms.image_pil.BaseTransformation.`
      """
      if not getattr(
          self.opts, "image_augmentation.random_resized_crop.enable"
      ):
          raise ValueError(
              "`image_augmentation.random_resized_crop.enable` must be set to True in input options."
          )
  
      aug_list = [
          image_pil.RandomResizedCrop(opts=self.opts, size=size)
      ]
  
      if getattr(
          self.opts, "image_augmentation.random_horizontal_flip.enable"
      ):
          aug_list.append(
              image_pil.RandomHorizontalFlip(opts=self.opts)
          )
  
      auto_augment = getattr(
          self.opts, "image_augmentation.auto_augment.enable"
      )
      rand_augment = getattr(
          self.opts, "image_augmentation.rand_augment.enable"
      )
      trivial_augment_wide = getattr(
          self.opts, "image_augmentation.trivial_augment_wide.enable"
      )
      if (
          bool(auto_augment)
          + bool(rand_augment)
          + bool(trivial_augment_wide)
          > 1
      ):
          logger.error(
              "Only one of AutoAugment, RandAugment and TrivialAugmentWide should be used."
          )
      elif auto_augment:
          aug_list.append(image_pil.AutoAugment(opts=self.opts))
      elif rand_augment:
          if getattr(
              self.opts,
              "image_augmentation.rand_augment.use_timm_library",
          ):
              aug_list.append(image_pil.RandAugmentTimm(opts=self.opts))
          else:
              aug_list.append(image_pil.RandAugment(opts=self.opts))
      elif trivial_augment_wide:
          aug_list.append(image_pil.TrivialAugmentWide(opts=self.opts))
  
      aug_list.append(image_pil.ToTensor(opts=self.opts))
  
      if getattr(self.opts, "image_augmentation.random_erase.enable"):
          aug_list.append(image_pil.RandomErasing(opts=self.opts))
  
      return Compose(opts=self.opts, img_transforms=aug_list)
  
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 3 for calling the BaseImageClassificationDataset obj's underlying member method code with example usage: obj._training_transforms(size) and returns: Compose