code: def cos_similarity(
      emb_a: torch.Tensor, emb_b: torch.Tensor, eps=torch.tensor(3.5e-4)
  ) -> torch.Tensor:
      """
      Calculate cosine similarities of the given two set of tensors. The output is an N by N
      matrix where N is the number of feature vectors.
  
      Args:
          a (Tensor):
              Matrix containing speaker representation vectors. (N x embedding_dim)
          b (Tensor):
              Matrix containing speaker representation vectors. (N x embedding_dim)
  
      Returns:
          res (Tensor):
              N by N matrix containing the cosine similarities of the values.
      """
      # If number of embedding count is 1, it creates nan values
      if emb_a.shape[0] == 1 or emb_b.shape[0] == 1:
          raise ValueError(
              f"Number of feature vectors should be greater than 1 but got {emb_a.shape} and {emb_b.shape}"
          )
      a_norm = emb_a / (torch.norm(emb_a, dim=1).unsqueeze(1) + eps)
      b_norm = emb_b / (torch.norm(emb_b, dim=1).unsqueeze(1) + eps)
      res = torch.mm(a_norm, b_norm.transpose(0, 1))
      res.fill_diagonal_(1)
      return res
  
imports: from typing import Dict, List, Tuple
  import torch
  from torch.linalg import eigh, eigvalsh
label_desc: Use image node_id 1 for calling a global function with example usage: cos_similarity(emb_a, emb_b, eps) and returns: res