code: def calculate_accuracy(threshold, dist, actual_issame):
      predict_issame = np.less(dist, threshold)
      tp = np.sum(np.logical_and(predict_issame, actual_issame))
      fp = np.sum(
          np.logical_and(predict_issame, np.logical_not(actual_issame))
      )
      tn = np.sum(
          np.logical_and(
              np.logical_not(predict_issame),
              np.logical_not(actual_issame),
          )
      )
      fn = np.sum(
          np.logical_and(np.logical_not(predict_issame), actual_issame)
      )
  
      tpr = 0 if (tp + fn == 0) else float(tp) / float(tp + fn)
      fpr = 0 if (fp + tn == 0) else float(fp) / float(fp + tn)
      acc = float(tp + tn) / dist.size
      return tpr, fpr, acc
  
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 2 for calling a global function with example usage: calculate_accuracy(threshold, dist, actual_issame) and returns: tpr,  fpr,  acc