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)
      far = float(false_accept) / float(n_diff)
      return val, far
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import argparse
  import sys
  import numpy
  from scipy import misc
  from sklearn.model_selection import KFold
  from scipy import interpolate
  import sklearn
  import cv2
  import math
  import datetime
  import pickle
  from sklearn.decomposition import PCA
  import mxnet
  from mxnet import ndarray
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