code: def get_splits(
      df,
      train_split_ratio=0.99,
      speaker_in_all_splits=False,
      rand_seed=0,
  ) -> Tuple[Dict[str, str], List[str]]:
      np.random.seed(rand_seed)
      dev_split_ratio = (1.0 - train_split_ratio) / 3
      grouped = list(df.groupby("client_id"))
      id_to_split = {}
      for _, cur_df in tqdm(grouped):
          cur_n_examples = len(cur_df)
          if speaker_in_all_splits and cur_n_examples < 3:
              continue
          cur_n_train = int(cur_n_examples * train_split_ratio)
          cur_n_dev = int(cur_n_examples * dev_split_ratio)
          cur_n_test = cur_n_examples - cur_n_dev - cur_n_train
          if speaker_in_all_splits and cur_n_dev * cur_n_test == 0:
              cur_n_dev, cur_n_test = 1, 1
              cur_n_train = cur_n_examples - cur_n_dev - cur_n_test
          cur_indices = cur_df.index.tolist()
          cur_shuffled_indices = np.random.permutation(cur_n_examples)
          cur_shuffled_indices = [
              cur_indices[i] for i in cur_shuffled_indices
          ]
          cur_indices_by_split = {
              "train": cur_shuffled_indices[:cur_n_train],
              "dev": cur_shuffled_indices[
                  cur_n_train : cur_n_train + cur_n_dev
              ],
              "test": cur_shuffled_indices[cur_n_train + cur_n_dev :],
          }
          for split in SPLITS:
              for i in cur_indices_by_split[split]:
                  id_ = df["id"].loc[i]
                  id_to_split[id_] = split
      return id_to_split, sorted(df["client_id"].unique())
  
file_path: fairseq/examples/speech_synthesis/preprocessing/get_common_voice_audio_manifest.py
imports: import argparse
  import logging
  from pathlib import Path
  from collections import defaultdict
  from typing import List, Dict, Tuple
  import pandas
  import numpy
  import torchaudio
  from tqdm import tqdm
  from examples.speech_to_text.data_utils import load_df_from_tsv, save_df_to_tsv
label_desc: Use image node_id 2 for calling a global function with example usage: get_splits(df, train_split_ratio, speaker_in_all_splits, rand_seed) and returns: id_to_split,  sorted