code: def _get_inter_splits_by_group(
      items_and_groups, split_probs, split_number
  ):
      """Split items to train/dev/test, so all items in group go into same split.
  
      Each group contains all the samples from the same speaker ID. The samples are
      splitted so that all each speaker belongs to exactly one split.
  
      Args:
        items_and_groups: Sequence of (item_id, group_id) pairs.
        split_probs: List of (split_name, prob), e.g. [('train', 0.6), ('dev', 0.2),
          ('test', 0.2)]
        split_number: Generated splits should change with split_number.
  
      Returns:
        Dictionary that looks like {split name -> set(ids)}.
      """
      groups = sorted(
          set(group_id for item_id, group_id in items_and_groups)
      )
      rng = np.random.RandomState(split_number)
      rng.shuffle(groups)
  
      split_boundaries = _compute_split_boundaries(
          split_probs, len(groups)
      )
      group_id_to_split = {}
      for split_name, i_start, i_end in split_boundaries:
          for i in range(i_start, i_end):
              group_id_to_split[groups[i]] = split_name
  
      split_to_ids = collections.defaultdict(list)
      for item_id, group_id in items_and_groups:
          split = group_id_to_split[group_id]
          split_to_ids[split].append(item_id)
  
      return split_to_ids
  
file_path: datasets/tensorflow_datasets/audio/dementiabank.py
imports: from __future__ import annotations
  import collections
  import os
  import textwrap
  import numpy
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  import tensorflow_datasets.public_api
label_desc: Use image node_id 2 for calling a global function with example usage: _get_inter_splits_by_group(items_and_groups, split_probs, split_number) and returns: split_to_ids