code: def build_spk_hashtable(hparams):
      """
      This function builds a dictionary of speaker-utterance pairs to be used in dynamic mixing
      """
      wsj0_utterances = glob.glob(
          os.path.join(hparams["base_folder_dm"], "**/*.wav"),
          recursive=True,
      )
  
      spk_hashtable = {}
      for utt in wsj0_utterances:
          spk_id = Path(utt).stem[:3]
          assert (
              torchaudio.info(utt).sample_rate == hparams["sample_rate"]
          )
  
          # e.g. 2speakers/wav8k/min/tr/mix/019o031a_0.27588_01vo030q_-0.27588.wav
          # id of speaker 1 is 019 utterance id is o031a
          # id of speaker 2 is 01v utterance id is 01vo030q
  
          if spk_id not in spk_hashtable.keys():
              spk_hashtable[spk_id] = [utt]
          else:
              spk_hashtable[spk_id].append(utt)
  
      # calculate weights for each speaker ( len of list of utterances)
      spk_weights = [
          len(spk_hashtable[x]) for x in spk_hashtable.keys()
      ]
  
      return spk_hashtable, spk_weights
  
file_path: speechbrain/recipes/WSJ0Mix/separation/dynamic_mixing.py
imports: import speechbrain
  import numpy
  import torch
  import torchaudio
  import glob
  import os
  from pathlib import Path
  import random
  from speechbrain.processing.signal_processing import rescale
  from speechbrain.dataio.batch import PaddedBatch
label_desc: Use image node_id 1 for calling a global function with example usage: build_spk_hashtable(hparams) and returns: spk_hashtable,  spk_weights