code: def embedding_computation_loop(split, set_loader, stat_file):
      """Extracts embeddings for a given dataset loader."""
  
      # Note: We use speechbrain.processing.PLDA_LDA.StatObject_SB type to store embeddings.
      # Extract embeddings (skip if already done).
      if not os.path.isfile(stat_file):
          logger.debug("Extracting deep embeddings and diarizing")
          embeddings = np.empty(
              shape=[0, params["emb_dim"]], dtype=np.float64
          )
          modelset = []
          segset = []
  
          # Different data may have different statistics.
          params["mean_var_norm_emb"].count = 0
  
          for batch in set_loader:
              ids = batch.id
              wavs, lens = batch.sig
  
              mod = [x for x in ids]
              seg = [x for x in ids]
              modelset = modelset + mod
              segset = segset + seg
  
              # Embedding computation.
              emb = (
                  compute_embeddings(wavs, lens)
                  .contiguous()
                  .squeeze(1)
                  .cpu()
                  .numpy()
              )
              embeddings = np.concatenate((embeddings, emb), axis=0)
  
          modelset = np.array(modelset, dtype="|O")
          segset = np.array(segset, dtype="|O")
  
          # Intialize variables for start, stop and stat0.
          s = np.array([None] * embeddings.shape[0])
          b = np.array([[1.0]] * embeddings.shape[0])
  
          stat_obj = StatObject_SB(
              modelset=modelset,
              segset=segset,
              start=s,
              stop=s,
              stat0=b,
              stat1=embeddings,
          )
          logger.debug("Saving Embeddings...")
          stat_obj.save_stat_object(stat_file)
  
      else:
          logger.debug(
              "Skipping embedding extraction (as already present)."
          )
          logger.debug("Loading previously saved embeddings.")
  
          with open(stat_file, "rb") as in_file:
              stat_obj = pickle.load(in_file)
  
      return stat_obj
  
imports: import os
  import sys
  import torch
  import logging
  import pickle
  import json
  import glob
  import shutil
  import numpy
  import speechbrain
  from tqdm.contrib import tqdm
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.distributed import run_on_main
  from speechbrain.processing.PLDA_LDA import StatObject_SB
  from speechbrain.processing import diarization
  from speechbrain.utils.DER import DER
  from speechbrain.dataio.dataio import read_audio
  from speechbrain.dataio.dataio import read_audio_multichannel
label_desc: Use image node_id 2 for calling a global function with example usage: embedding_computation_loop(split, set_loader, stat_file) and returns: stat_obj