code: def get_train_val_datasets(
      opts: argparse.Namespace, *args, **kwargs
  ) -> Tuple[BaseDataset, Optional[BaseDataset]]:
      """Helper function to build a dataset for training and validation.
  
      Args:
          opts: Command-line arguments
  
      Returns:
          Training and (optionally) validation datasets.
      """
  
      disable_val = getattr(opts, "dataset.disable_val")
      is_master_node = is_master(opts)
      train_dataset = build_dataset_from_registry(
          opts, is_training=True, is_evaluation=False, *args, **kwargs
      )
      if is_master_node:
          logger.log("Training dataset details are given below")
          print(train_dataset)
  
      valid_dataset = None
      if not disable_val:
          valid_dataset = build_dataset_from_registry(
              opts,
              is_training=False,
              is_evaluation=False,
              *args,
              **kwargs,
          )
          if is_master_node:
              logger.log("Validation dataset details are given below")
              print(valid_dataset)
  
      return train_dataset, valid_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 3 for calling a global function with example usage: get_train_val_datasets(opts) and returns: train_dataset,  valid_dataset