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: Adds dataset related arguments to the parser.
  
  Args:
      parser: An argparse.Namespace instance
  
  Returns:
      Input argparse.Namespace instance with additional arguments.
docstr_tok: ["Adds","dataset","related","arguments","to","the","parser",".","Args",":","parser",":","An","argparse.Namespace","instance","Returns",":","Input","argparse.Namespace","instance","with","additional","arguments","."]
code: def add_arguments(
      cls, parser: argparse.ArgumentParser
  ) -> argparse.ArgumentParser:
      """
      Adds dataset related arguments to the parser.
  
      Args:
          parser: An argparse.Namespace instance
  
      Returns:
          Input argparse.Namespace instance with additional arguments.
      """
      if cls != BaseImageClassificationDataset:
          # Don't re-register arguments in subclasses that don't override `add_arguments()`.
          return parser
      group = parser.add_argument_group(title=cls.__name__)
  
      group.add_argument(
          "--dataset.num-samples-per-category",
          type=int,
          default=-1,
          help="Number of samples to use per category. If set to -1, all samples will be used.",
      )
  
      # sample efficient training
      group.add_argument(
          "--dataset.sample-efficient-training.enable",
          action="store_true",
          default=False,
          help="Enabling this flag allows us to use sample efficient training. "
          "Currently only tested on classification tasks.",
      )
      group.add_argument(
          "--dataset.sample-efficient-training.sample-confidence",
          type=float,
          default=0.5,
          help="Confidence for identifying samples as easy or hard. If the "
          "predicted classification probability of a sample is greater than "
          "this value, then sample is classified as easy. Otherwise, it is "
          "classified as hard. Defaults to 0.5.",
      )
      group.add_argument(
          "--dataset.sample-efficient-training.find-easy-samples-every-k-epochs",
          type=int,
          default=5,
          help="Find easy samples after every K epochs. Defaults to 5.",
      )
      group.add_argument(
          "--dataset.sample-efficient-training.min-sample-frequency",
          type=int,
          default=5,
          help="Frequency that sample has been classified as easy for N number of times."
          "Defaults to 5.",
      )
  
      return parser
  
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 2 for calling the BaseImageClassificationDataset obj's underlying member method code with example usage: obj.add_arguments(cls, parser) and returns: parser, parser