class_docstr: Perform spectral clustering by calculating spectral embeddings then run k-means clustering
  algorithm on the spectral embeddings.
class_docstr_tok: ["Perform","spectral","clustering","by","calculating","spectral","embeddings","then","run","k-means","clustering","algorithm","on","the","spectral","embeddings","."]
docstr: Perform k-means clustering on spectral embeddings. To alleviate the effect of randomness,
  k-means clustering is performed for (self.n_random_trials) times then the final labels are obtained
  by taking a majority vote. If speed is the major concern, self.n_random_trials should be set to 1.
  n_random_trials=30 is recommended to see an improved result.
  
  Args:
      affinity (Tensor):
          Affinity matrix input
      cuda (torch.bool):
          Use cuda for spectral clustering if cuda=True
      device (torch.device):
          Torch device variable
  
  Returns:
      labels (Tensor):
          clustering label output
code: def clusterSpectralEmbeddings(
      self,
      affinity: torch.Tensor,
      cuda: bool = False,
      device: torch.device = torch.device("cpu"),
  ) -> torch.Tensor:
      """
      Perform k-means clustering on spectral embeddings. To alleviate the effect of randomness,
      k-means clustering is performed for (self.n_random_trials) times then the final labels are obtained
      by taking a majority vote. If speed is the major concern, self.n_random_trials should be set to 1.
      n_random_trials=30 is recommended to see an improved result.
  
      Args:
          affinity (Tensor):
              Affinity matrix input
          cuda (torch.bool):
              Use cuda for spectral clustering if cuda=True
          device (torch.device):
              Torch device variable
  
      Returns:
          labels (Tensor):
              clustering label output
  
      """
      spectral_emb = self.getSpectralEmbeddings(
          affinity, n_spks=self.n_clusters, cuda=cuda
      )
      labels_set = []
  
      for random_state_seed in range(
          self.random_state, self.random_state + self.n_random_trials
      ):
          _labels = kmeans_torch(
              X=spectral_emb,
              num_clusters=self.n_clusters,
              random_state=random_state_seed,
              device=device,
          )
          labels_set.append(_labels)
      stacked_labels = torch.stack(labels_set)
      label_index = torch.mode(torch.mode(stacked_labels, 0)[1])[0]
      labels = stacked_labels[label_index]
      return labels
  
imports: from typing import Dict, List, Tuple
  import torch
  from torch.linalg import eigh, eigvalsh
label_desc: Use image node_id 3 for calling the SpectralClustering obj's underlying member method code with example usage: obj.clusterSpectralEmbeddings(affinity, cuda, device) and returns: labels