class_docstr: Normalized Maximum Eigengap based Spectral Clustering (NME-SC)
  uses Eigengap analysis to get an estimated p-value for
  affinity binarization and an estimated number of speakers.
  
  p_value (also referred to as p_neighbors) is for taking
  top p number of affinity values and convert those to 1 while
  convert the rest of values to 0.
  
  p_value can be also tuned on a development set without performing
  NME-analysis. Fixing p_value brings about significantly faster clustering
  speed, but the performance is limited to the development set.
  
  References:
      Tae Jin Park et al., Auto-Tuning Spectral Clustering for Speaker Diarization
      Using Normalized Maximum Eigengap, IEEE Signal Processing Letters 27 (2019),
      https://arxiv.org/abs/2003.02405
  
  Args:
      Please refer to def __init__().
  
  Methods:
      NMEanalysis():
          Performs NME-analysis to estimate p_value and the number of speakers
      subsampleAffinityMat(nme_mat_size):
          Subsamples the number of speakers to reduce the computational load
      getPvalueList():
          Generates a list containing p-values that need to be examined.
      getEigRatio(p_neighbors):
          Calculates g_p, which is a ratio between p_neighbors and the maximum eigengap
      getLamdaGaplist(lambdas):
          Calculates lambda gap values from an array contains lambda values
      estimateNumofSpeakers(affinity_mat):
          Estimates the number of speakers using lambda gap list
class_docstr_tok: ["Normalized","Maximum","Eigengap","based","Spectral","Clustering","(","NME-SC",")","uses","Eigengap","analysis","to","get","an","estimated","p-value","for","affinity","binarization","and","an","estimated","number","of","speakers",".","p_value","(","also","referred","to","as","p_neighbors",")","is","for","taking","top","p","number","of","affinity","values","and","convert","those","to","1","while","convert","the","rest","of","values","to","0.","p_value","can","be","also","tuned","on","a","development","set","without","performing","NME-analysis",".","Fixing","p_value","brings","about","significantly","faster","clustering","speed",",","but","the","performance","is","limited","to","the","development","set",".","References",":","Tae","Jin","Park","et","al.",",","Auto-Tuning","Spectral","Clustering","for","Speaker","Diarization","Using","Normalized","Maximum","Eigengap",",","IEEE","Signal","Processing","Letters","27","(","2019",")",",","https",":","\/\/arxiv.org\/abs\/2003.02405","Args",":","Please","refer","to","def","__init__","(",")",".","Methods",":","NMEanalysis","(",")",":","Performs","NME-analysis","to","estimate","p_value","and","the","number","of","speakers","subsampleAffinityMat","(","nme_mat_size",")",":","Subsamples","the","number","of","speakers","to","reduce","the","computational","load","getPvalueList","(",")",":","Generates","a","list","containing","p-values","that","need","to","be","examined",".","getEigRatio","(","p_neighbors",")",":","Calculates","g_p",",","which","is","a","ratio","between","p_neighbors","and","the","maximum","eigengap","getLamdaGaplist","(","lambdas",")",":","Calculates","lambda","gap","values","from","an","array","contains","lambda","values","estimateNumofSpeakers","(","affinity_mat",")",":","Estimates","the","number","of","speakers","using","lambda","gap","list"]
docstr: Perform subsampling of affinity matrix.
  This subsampling is for calculational complexity, not for performance.
  The smaller nme_mat_size is,
      - the bigger the chance of missing a speaker.
      - the faster p-value estimation speed (based on eigen decomposition).
  
  The recommended nme_mat_size is 250~750.
  However, if there are speakers who speak for very short period of time in the recording,
  this subsampling might make the system miss underrepresented speakers.
  Use this variable with caution.
  
  Args:
      nme_mat_size (int):
          The targeted matrix size
  
  Returns:
      subsample_ratio (float):
          The ratio between nme_mat_size and the original matrix size
code: def subsampleAffinityMat(self, nme_mat_size: int) -> torch.Tensor:
      """
      Perform subsampling of affinity matrix.
      This subsampling is for calculational complexity, not for performance.
      The smaller nme_mat_size is,
          - the bigger the chance of missing a speaker.
          - the faster p-value estimation speed (based on eigen decomposition).
  
      The recommended nme_mat_size is 250~750.
      However, if there are speakers who speak for very short period of time in the recording,
      this subsampling might make the system miss underrepresented speakers.
      Use this variable with caution.
  
      Args:
          nme_mat_size (int):
              The targeted matrix size
  
      Returns:
          subsample_ratio (float):
              The ratio between nme_mat_size and the original matrix size
      """
      subsample_ratio = torch.max(
          torch.tensor(1),
          torch.tensor(self.mat.shape[0] / nme_mat_size),
      ).type(torch.int)
      self.mat = self.mat[
          :: subsample_ratio.item(), :: subsample_ratio.item()
      ]
      return subsample_ratio
  
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 NMESC obj's underlying member method code with example usage: obj.subsampleAffinityMat(nme_mat_size) and returns: subsample_ratio