code: def split_by_ratios(dataset, split_ratios):
      """Randomly split a dataset into non-overlapping new datasets of given ratios.
  
      Args:
          dataset (torch.utils.data.Dataset): Dataset to be split.
          split_ratios (list): Ratios of splits to be produced, where 0 < sum(split_ratios) <= 1.
  
      Returns:
          [List]: A list of subsets.
  
      Examples:
          >>> import torch
          >>> from kale.loaddata.dataset_access import split_by_ratios
          >>> subset1, subset2 = split_by_ratios(range(10), [0.3, 0.7])
          >>> len(subset1)
          3
          >>> len(subset2)
          7
          >>> subset1, subset2 = split_by_ratios(range(10), [0.3])
          >>> len(subset1)
          3
          >>> len(subset2)
          7
          >>> subset1, subset2, subset3 = split_by_ratios(range(10), [0.3, 0.3])
          >>> len(subset1)
          3
          >>> len(subset2)
          3
          >>> len(subset3)
          4
      """
      n_total = len(dataset)
      ratio_sum = sum(split_ratios)
      if ratio_sum > 1 or ratio_sum <= 0:
          raise ValueError("The sum of ratios should be in range(0, 1]")
      elif ratio_sum == 1:
          split_ratios_ = split_ratios[:-1]
      else:
          split_ratios_ = split_ratios.copy()
      split_sizes = [int(n_total * ratio_) for ratio_ in split_ratios_]
      split_sizes.append(n_total - sum(split_sizes))
  
      return torch.utils.data.random_split(dataset, split_sizes)
  
file_path: pykale/kale/loaddata/dataset_access.py
imports: import torch
  import torch.utils.data
label_desc: Use image node_id 2 for calling a global function with example usage: split_by_ratios(dataset, split_ratios) and returns: torch