code: def calculate_val_far(threshold, dist, actual_issame):
      predict_issame = np.less(dist, threshold)
      true_accept = np.sum(
          np.logical_and(predict_issame, actual_issame)
      )
      false_accept = np.sum(
          np.logical_and(predict_issame, np.logical_not(actual_issame))
      )
      n_same = np.sum(actual_issame)
      n_diff = np.sum(np.logical_not(actual_issame))
      # print(true_accept, false_accept)
      # print(n_same, n_diff)
      val = float(true_accept) / (float(n_same) + 1e-8)
      far = float(false_accept) / (float(n_diff) + 1e-8)
      return val, far
  
file_path: insightface/recognition/arcface_paddle/utils/verification.py
imports: import datetime
  import os
  import numpy
  import sklearn
  from scipy import interpolate
  from sklearn.decomposition import PCA
  from sklearn.model_selection import KFold
label_desc: Use image node_id 4 for calling a global function with example usage: calculate_val_far(threshold, dist, actual_issame) and returns: val,  far