code: def split_different_speakers(speaker_dict, test_spk_id):
      """Constructs train, validation and test sets that do not share common
      speakers. There are two different speakers in each session. Train set is
      constituted of 4 sessions (8 speakers), while validation set and test set
      contain each 1 speaker. If test_spk_id is 1, then speaker 2 is selected
      automatically for validation set, and training set contains other 8 speakers.
      If test_spk_id is 2, then speaker 1 is selected for validation set.
  
      Arguments
      ---------
      speaker_dict: dict
          a dictionary of speaker id and its corresponding audio information
      test_spk_id: int
          Id of speaker used for test set, 10 speakers in total.
          Session1 contains speaker 1&2, Session2 contains speaker 3&4, ...
  
      Returns
      ------
      dictionary containing train, valid, and test splits.
      """
      data_split = {k: [] for k in ["train", "valid", "test"]}
      data_split["test"].extend(speaker_dict[str(test_spk_id)])
  
      # use the speaker in the same session as validation set
      if test_spk_id % 2 == 0:
          valid_spk_num = test_spk_id - 1
      else:
          valid_spk_num = test_spk_id + 1
  
      data_split["valid"].extend(speaker_dict[str(valid_spk_num)])
  
      for i in range(1, 11):
          if i != valid_spk_num and i != test_spk_id:
              data_split["train"].extend(speaker_dict[str(i)])
  
      return data_split
  
file_path: speechbrain/recipes/IEMOCAP/emotion_recognition/iemocap_prepare.py
imports: import os
  import re
  import json
  import random
  import logging
  from speechbrain.dataio.dataio import read_audio
label_desc: Use image node_id 4 for calling a global function with example usage: split_different_speakers(speaker_dict, test_spk_id) and returns: data_split