code: def getMultiScaleCosAffinityMatrix(
      multiscale_weights: torch.Tensor,
      embeddings_in_scales: List[torch.Tensor],
      timestamps_in_scales: List[torch.Tensor],
      device: torch.device = torch.device("cpu"),
  ) -> torch.Tensor:
      """
      Calculate cosine similarity values among speaker embeddings for each scale then
      apply multiscale weights to calculate the fused similarity matrix.
      NOTE: Due to CUDA memory limit, the embedding vectors in embeddings_in_scales are stored in `cpu` device.
  
      Args:
          multiscale_weights (Tensor):
              Tensor containing multiscale weights
              Dimensions: (Number of scales) x 1
          embeddings_in_scales (list):
              List containing split embedding tensors by each scale
          timestamps_in_scales (list):
              List containing split timestamps tensors by each scale
          device (torch.device):
              Torch device variable
  
      Returns:
          fused_sim_d (Tensor):
              An affinity matrix that is obtained by calculating the weighted sum of
              the multiple affinity matrices from the different scales.
      """
      multiscale_weights = torch.squeeze(multiscale_weights, dim=0).to(
          device
      )
      session_scale_mapping_list = get_argmin_mat(timestamps_in_scales)
      scale_list = list(range(len(timestamps_in_scales)))
      fused_sim_d = torch.zeros(
          len(timestamps_in_scales[-1]), len(timestamps_in_scales[-1])
      ).to(device)
      for scale_idx in scale_list:
          mapping_argmat = session_scale_mapping_list[scale_idx]
          emb_t = embeddings_in_scales[scale_idx].half().to(device)
          score_mat_torch = getCosAffinityMatrix(emb_t)
          repeat_list = getRepeatedList(
              mapping_argmat, torch.tensor(score_mat_torch.shape[0])
          ).to(device)
          repeated_tensor_0 = torch.repeat_interleave(
              score_mat_torch, repeats=repeat_list, dim=0
          ).to(device)
          repeated_tensor_1 = torch.repeat_interleave(
              repeated_tensor_0, repeats=repeat_list, dim=1
          ).to(device)
          fused_sim_d += (
              multiscale_weights[scale_idx] * repeated_tensor_1
          )
      return fused_sim_d
  
imports: from typing import Dict, List, Tuple
  import torch
  from torch.linalg import eigh, eigvalsh
label_desc: Use image node_id 15 for calling a global function with example usage: getMultiScaleCosAffinityMatrix(multiscale_weights, embeddings_in_scales, timestamps_in_scales, device) and returns: fused_sim_d