docstr: The class controlling how the source and target domains are
      iterated over.
  
  Args:
      source_access (DatasetAccess): accessor for the source dataset
      target_access (DatasetAccess): accessor for the target dataset
      config_weight_type (WeightingType, optional): The weight type for sampling. Defaults to 'natural'.
      config_size_type (DatasetSizeType, optional): Which dataset size to use to define the number of epochs vs
          batch_size. Defaults to DatasetSizeType.Max.
      valid_split_ratio (float, optional): ratio for the validation part of the train dataset. Defaults to 0.1.
      source_sampling_config (SamplingConfig, optional): How to sample from the source. Defaults to None
          (=> RandomSampler).
      target_sampling_config (SamplingConfig, optional): How to sample from the target. Defaults to None
          (=> RandomSampler).
      n_fewshot (int, optional): Number of target samples for which the label may be used,
          to define the few-shot, semi-supervised setting. Defaults to None.
      random_state ([int|np.random.RandomState], optional): Used for deterministic sampling/few-shot label
          selection. Defaults to None.
      class_ids (list, optional): List of chosen subset of class ids. Defaults to None (=> All Classes).
  Examples::
      >>> dataset = MultiDomainDatasets(source_access, target_access)
code: def __init__(
      self,
      source_access: DatasetAccess,
      target_access: DatasetAccess,
      config_weight_type="natural",
      config_size_type=DatasetSizeType.Max,
      valid_split_ratio=0.1,
      source_sampling_config=None,
      target_sampling_config=None,
      n_fewshot=None,
      random_state=None,
      class_ids=None,
  ):
      """The class controlling how the source and target domains are
          iterated over.
  
      Args:
          source_access (DatasetAccess): accessor for the source dataset
          target_access (DatasetAccess): accessor for the target dataset
          config_weight_type (WeightingType, optional): The weight type for sampling. Defaults to 'natural'.
          config_size_type (DatasetSizeType, optional): Which dataset size to use to define the number of epochs vs
              batch_size. Defaults to DatasetSizeType.Max.
          valid_split_ratio (float, optional): ratio for the validation part of the train dataset. Defaults to 0.1.
          source_sampling_config (SamplingConfig, optional): How to sample from the source. Defaults to None
              (=> RandomSampler).
          target_sampling_config (SamplingConfig, optional): How to sample from the target. Defaults to None
              (=> RandomSampler).
          n_fewshot (int, optional): Number of target samples for which the label may be used,
              to define the few-shot, semi-supervised setting. Defaults to None.
          random_state ([int|np.random.RandomState], optional): Used for deterministic sampling/few-shot label
              selection. Defaults to None.
          class_ids (list, optional): List of chosen subset of class ids. Defaults to None (=> All Classes).
      Examples::
          >>> dataset = MultiDomainDatasets(source_access, target_access)
      """
      weight_type = WeightingType(config_weight_type)
      size_type = DatasetSizeType(config_size_type)
  
      if weight_type is WeightingType.PRESET0:
          self._source_sampling_config = SamplingConfig(
              class_weights=np.arange(source_access.n_classes(), 0, -1)
          )
          self._target_sampling_config = SamplingConfig(
              class_weights=np.random.randint(
                  1, 4, size=target_access.n_classes()
              )
          )
      elif weight_type is WeightingType.BALANCED:
          self._source_sampling_config = SamplingConfig(balance=True)
          self._target_sampling_config = SamplingConfig(balance=True)
      elif weight_type not in WeightingType:
          raise ValueError(f"Unknown weighting method {weight_type}.")
      else:
          self._source_sampling_config = SamplingConfig()
          self._target_sampling_config = SamplingConfig()
  
      self._source_access = source_access
      self._target_access = target_access
      self._valid_split_ratio = valid_split_ratio
      # self._source_sampling_config = (
      #     source_sampling_config
      #     if source_sampling_config is not None
      #     else SamplingConfig()
      # )
      # self._target_sampling_config = (
      #     target_sampling_config
      #     if target_sampling_config is not None
      #     else SamplingConfig()
      # )
      self._size_type = size_type
      self._n_fewshot = n_fewshot
      self._random_state = check_random_state(random_state)
      self._source_by_split: Dict[str, torch.utils.data.Subset] = {}
      self._labeled_target_by_split = None
      self._target_by_split: Dict[str, torch.utils.data.Subset] = {}
      self.class_ids = class_ids
  
imports: import logging
  import os
  from enum import Enum
  from typing import Any, Callable, cast, Dict, List, Optional, Tuple
  import numpy
  import torch.utils.data
  from sklearn.utils import check_random_state
  from torchvision.datasets import VisionDataset
  from torchvision.datasets.folder import default_loader, has_file_allowed_extension, IMG_EXTENSIONS
  from kale.loaddata.dataset_access import DatasetAccess, get_class_subset, split_by_ratios
  from kale.loaddata.sampler import FixedSeedSamplingConfig, get_labels, MultiDataLoader, SamplingConfig
label_desc: Use image node_id 1 to create a new MultiDomainDatasets object from inherited base classes: DomainsDatasetBase with example: obj = MultiDomainDatasets(source_access, target_access, config_weight_type, config_size_type, valid_split_ratio, source_sampling_config, target_sampling_config, n_fewshot, random_state, class_ids)