class_docstr: Base class for creating datasets. Sub-classes must implement __getitem__,
  _training_transforms, and _validation_transforms functions.
  
  Args:
      opts: Command-line arguments
      is_training: Training mode or not. Defaults to True.
      is_evaluation: Evaluation mode or not. Defaults to False.
  
  ...note::
      `is_training` is used to indicate whether the dataset is used for training or
      validation. On the other hand, `is_evaluation` mode is used to indicate the
      dataset is used for testing.
  
      Theoretically, `is_training=False` and `is_evaluation=True` should be the same.
      However, for some datasets (especially segmentation), validation dataset
      transforms are different from test transforms because each image has different
      resolution, making it difficult to construct batches. Therefore, we treat these
      two modes different.
  
      For datasets, where validation and testing transforms are the same, we set
      evaluation transforms the same as the validation transforms.
class_docstr_tok: ["Base","class","for","creating","datasets",".","Sub-classes","must","implement","__getitem__",",","_training_transforms",",","and","_validation_transforms","functions",".","Args",":","opts",":","Command-line","arguments","is_training",":","Training","mode","or","not",".","Defaults","to","True",".","is_evaluation",":","Evaluation","mode","or","not",".","Defaults","to","False",".","...","note",":",":","`","is_training","`","is","used","to","indicate","whether","the","dataset","is","used","for","training","or","validation",".","On","the","other","hand",",","`","is_evaluation","`","mode","is","used","to","indicate","the","dataset","is","used","for","testing",".","Theoretically",",","`","is_training=False","`","and","`","is_evaluation=True","`","should","be","the","same",".","However",",","for","some","datasets","(","especially","segmentation",")",",","validation","dataset","transforms","are","different","from","test","transforms","because","each","image","has","different","resolution",",","making","it","difficult","to","construct","batches",".","Therefore",",","we","treat","these","two","modes","different",".","For","datasets",",","where","validation","and","testing","transforms","are","the","same",",","we","set","evaluation","transforms","the","same","as","the","validation","transforms","."]
docstr: Add dataset-specific arguments
code: def add_arguments(
      cls, parser: argparse.ArgumentParser
  ) -> argparse.ArgumentParser:
      """Add dataset-specific arguments"""
      if cls != BaseDataset:
          # Don't re-register arguments in subclasses that don't override
          # `add_arguments()`.
          return parser
  
      group = parser.add_argument_group(cls.__name__)
      group.add_argument(
          "--dataset.root-train",
          type=str,
          default="",
          help="Root location of train dataset",
      )
      group.add_argument(
          "--dataset.root-val",
          type=str,
          default="",
          help="Root location of valid dataset",
      )
      group.add_argument(
          "--dataset.root-test",
          type=str,
          default="",
          help="Root location of test dataset",
      )
      group.add_argument(
          "--dataset.disable-val",
          action="store_true",
          default=False,
          help="Disable validation during training",
      )
  
      group.add_argument(
          "--dataset.name",
          type=str,
          default=None,
          help="Dataset name (e.g., imagenet). Defaults to None.",
      )
      group.add_argument(
          "--dataset.category",
          type=str,
          default=None,
          help="Dataset category (e.g., segmentation, classification). Defaults to None.",
      )
      group.add_argument(
          "--dataset.percentage-of-samples",
          type=float,
          default=100.0,
          help="Percentage of samples to use from the dataset.",
      )
      group.add_argument(
          "--dataset.sample-selection-random-seed",
          type=int,
          default=0,
          help="Random seed for selecting a subset of samples to use from the dataset.",
      )
      group.add_argument(
          "--dataset.train-batch-size0",
          default=128,
          type=int,
          help="Training batch size on GPU-0. Defaults to 128. "
          "Note that we scale it depending on total GPUs available for training. For"
          " example, if 2 GPUs are available and value of `dataset.train_batch_size0`"
          " is 128, then effective batch size will be 256.",
      )
      group.add_argument(
          "--dataset.val-batch-size0",
          default=1,
          type=int,
          help="Batch size on GPU-0 for validation. Defaults to 1. "
          "Note that we scale it depending on total GPUs available for training. For"
          " example, if 2 GPUs are available and value of `dataset.val_batch_size0`"
          " is 128, then effective batch size will be 256.",
      )
      group.add_argument(
          "--dataset.eval-batch-size0",
          default=1,
          type=int,
          help="Batch size on GPU-0 for testing or evaluation. Defaults to 1."
          "Note that we scale it automatically depending on total number of GPUs"
          " available. We recommend to run evaluation on a single GPU machine.",
      )
      group.add_argument(
          "--dataset.workers",
          default=-1,
          type=int,
          help="Number of data workers. Defaults to -1."
          "When number of workers are specified as -1, then total number of workers"
          " is equal to the number of available CPUs.",
      )
  
      group.add_argument(
          "--dataset.persistent-workers",
          action="store_true",
          default=False,
          help="Enabling this argument allows us to use same workers for loading data"
          " throughout the training. Defaults to False.",
      )
      group.add_argument(
          "--dataset.pin-memory",
          action="store_true",
          default=False,
          help="Enabling this allows us to use pin memory option in data loader. "
          "Defaults to False.",
      )
      group.add_argument(
          "--dataset.prefetch-factor",
          type=int,
          default=2,
          help="Number of samples loaded in advance by each data worker. Defaults to 2.",
      )
  
      group.add_argument(
          "--dataset.padding-index",
          type=int,
          default=None,
          help="Padding index for text vocabulary. Defaults to None.",
      )
  
      group.add_argument(
          "--dataset.text-vocab-size",
          type=int,
          default=-1,
          help="Text vocabulary size. Defaults to -1.",
      )
      group.add_argument(
          "--dataset.text-context-length",
          type=int,
          default=None,
          help="Context length for text encoder. Defaults to None.",
      )
  
      return parser
  
imports: from __future__ import annotations
  import argparse
  from abc import ABC
  from typing import Any, Dict, Optional, TypedDict
  import torch
  from PIL import Image
  from torch.utils import data
  from data.transforms import BaseTransformation
  from data.video_reader import get_video_reader
  from utils import logger
label_desc: Use image node_id 2 for calling the BaseDataset obj's underlying member method code with example usage: obj.add_arguments(cls, parser) and returns: parser, parser