code: def build_dataset_from_registry(
      opts: argparse.Namespace,
      is_training: bool = True,
      is_evaluation: bool = False,
      *args,
      **kwargs,
  ) -> BaseDataset:
      """Helper function to build a dataset from dataset registry
  
      Args:
          opts: Command-line arguments
          is_training: Training mode or not. Defaults to True.
          is_evaluation: Evaluation mode or not. Defaults to False.
  
      Returns:
          An instance of BaseDataset
  
  
      ...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 (e.g., in ImageNet
          object classification).
      """
  
      dataset_category = getattr(opts, "dataset.category")
  
      if dataset_category is None:
          logger.error(
              "Please specify dataset category using --dataset.category"
          )
  
      dataset_name = getattr(opts, f"dataset.name")
      if dataset_name is None:
          logger.error(
              "Please specify dataset name using --dataset.name"
          )
  
      dataset = DATASET_REGISTRY[dataset_name, dataset_category](
          opts=opts,
          is_training=is_training,
          is_evaluation=is_evaluation,
          *args,
          **kwargs,
      )
      return dataset
  
file_path: ml-cvnets/data/datasets/__init__.py
imports: import argparse
  from typing import Optional, Tuple
  from data.datasets.classification.base_image_classification_dataset import BaseImageClassificationDataset
  from data.datasets.classification.base_imagenet_shift_dataset import BaseImageNetShiftDataset
  from data.datasets.dataset_base import BaseDataset, BaseImageDataset, BaseVideoDataset
  from data.datasets.detection.base_detection import BaseDetectionDataset
  from data.datasets.multi_modal_img_text import arguments_multi_modal_img_text
  from data.datasets.segmentation.base_segmentation import BaseImageSegmentationDataset
  from utils import logger
  from utils.ddp_utils import is_master
  from utils.registry import Registry
label_desc: Use image node_id 1 for calling a global function with example usage: build_dataset_from_registry(opts, is_training, is_evaluation) and returns: dataset