code: def get_embs_and_timestamps(
      multiscale_embeddings_and_timestamps, multiscale_args_dict
  ):
      """
      The embeddings and timestamps in multiscale_embeddings_and_timestamps dictionary are
      indexed by scale index. This function rearranges the extracted speaker embedding and
      timestamps by unique ID to make the further processing more convenient.
  
      Args:
          multiscale_embeddings_and_timestamps (dict):
              Dictionary of embeddings and timestamps for each scale.
          multiscale_args_dict (dict):
              Dictionary of scale information: window, shift and multiscale weights.
  
      Returns:
          embs_and_timestamps (dict)
              A dictionary containing embeddings and timestamps of each scale, indexed by unique ID.
      """
      embs_and_timestamps = {
          uniq_id: {}
          for uniq_id in multiscale_embeddings_and_timestamps[0][
              0
          ].keys()
      }
      if multiscale_args_dict["use_single_scale_clustering"]:
          _multiscale_args_dict = deepcopy(multiscale_args_dict)
          _multiscale_args_dict["scale_dict"] = {
              0: multiscale_args_dict["scale_dict"][0]
          }
          _multiscale_args_dict[
              "multiscale_weights"
          ] = multiscale_args_dict["multiscale_weights"][:1]
      else:
          _multiscale_args_dict = multiscale_args_dict
  
      embeddings, timestamps = multiscale_embeddings_and_timestamps[0]
      for uniq_id in embeddings.keys():
          embeddings_list, time_stamps_list, segment_index_list = (
              [],
              [],
              [],
          )
          for scale_idx in sorted(
              _multiscale_args_dict["scale_dict"].keys()
          ):
              (
                  embeddings,
                  timestamps,
              ) = multiscale_embeddings_and_timestamps[scale_idx]
              if len(embeddings[uniq_id]) != len(timestamps[uniq_id]):
                  raise ValueError(
                      "Mismatch of counts between embedding vectors and timestamps"
                  )
              time_stamps_tensor = torch.tensor(timestamps[uniq_id])
              embeddings_list.append(embeddings[uniq_id])
              segment_index_list.append(embeddings[uniq_id].shape[0])
              time_stamps_list.append(time_stamps_tensor)
  
          embs_and_timestamps[uniq_id]["multiscale_weights"] = (
              torch.tensor(_multiscale_args_dict["multiscale_weights"])
              .unsqueeze(0)
              .float()
          )
          embs_and_timestamps[uniq_id]["embeddings"] = torch.cat(
              embeddings_list, dim=0
          )
          embs_and_timestamps[uniq_id]["timestamps"] = torch.cat(
              time_stamps_list, dim=0
          )
          embs_and_timestamps[uniq_id][
              "multiscale_segment_counts"
          ] = torch.tensor(segment_index_list)
  
      return embs_and_timestamps
  
imports: import gc
  import json
  import math
  import os
  import shutil
  from copy import deepcopy
  from typing import Dict, List, Tuple, Union
  import numpy
  import omegaconf
  import soundfile
  import torch
  from pyannote.core import Annotation, Segment
  from tqdm import tqdm
  from nemo.collections.asr.data.audio_to_label import repeat_signal
  from nemo.collections.asr.parts.utils.longform_clustering import LongFormSpeakerClustering
  from nemo.collections.asr.parts.utils.offline_clustering import SpeakerClustering, get_argmin_mat, split_input_data
  from nemo.utils import logging
label_desc: Use image node_id 6 for calling a global function with example usage: get_embs_and_timestamps(multiscale_embeddings_and_timestamps, multiscale_args_dict) and returns: embs_and_timestamps