code: def calculate_eer(y_label, y_score):
      # y denotes groundtruth scores,
      # y_score denotes the prediction scores.
      from scipy.optimize import brentq
      from sklearn.metrics import roc_curve
      from scipy.interpolate import interp1d
  
      fpr, tpr, thresholds = roc_curve(y_label, y_score, pos_label=1)
      eer = brentq(lambda x: 1.0 - x - interp1d(fpr, tpr)(x), 0.0, 1.0)
      optimal_threshold = interp1d(fpr, thresholds)(eer)
      return eer, optimal_threshold
  
file_path: fairseq/examples/wav2vec/xlsr/scripts/eval_speaker_clf_task.py
imports: import numpy
  import sklearn
  from sklearn.metrics.pairwise import cosine_similarity
  from sklearn.preprocessing import StandardScaler
  from tqdm import tqdm
  import ipdb
  import logging
  import argparse
  from scipy.special import softmax
label_desc: Use image node_id 1 for calling a global function with example usage: calculate_eer(y_label, y_score) and returns: eer,  optimal_threshold