code: def _domain_stratified_split(
      domain_labels, n_partitions, split_ratios
  ):
      """Get domain stratified indices of random split. Samples with the same domain label will be split based on the
          given ratios. Then the indices of different domains within the same split will be concatenated.
  
      Args:
          domain_labels (array-like): Labels to indicate which domains the samples are from.
          n_partitions (int): Number of partitions to split, 2 <= n_partitions <= len(split_ratios) + 1.
          split_ratios (list): Ratios of splits to be produced, where 0 < sum(split_ratios) <= 1.
  
      Returns:
          [list]: Indices for different splits.
      """
      domains = np.unique(domain_labels)
      subset_idx = [[] for i in range(n_partitions)]
      for domain_label_ in domains:
          domain_idx = np.where(domain_labels == domain_label_)[0]
          subsets = split_by_ratios(
              torch.from_numpy(domain_idx), split_ratios
          )
          for i in range(n_partitions):
              subset_idx[i].append(domain_idx[subsets[i].indices])
  
      stratified_idx = []
      for i in range(n_partitions):
          stratified_idx.append(np.concatenate(subset_idx[i]))
  
      return stratified_idx
  
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 2 for calling a global function with example usage: _domain_stratified_split(domain_labels, n_partitions, split_ratios) and returns: stratified_idx