code: def verification2(
      template_norm_feats=None, unique_templates=None, p1=None, p2=None
  ):
      template2id = np.zeros((max(unique_templates) + 1, 1), dtype=int)
      for count_template, uqt in enumerate(unique_templates):
          template2id[uqt] = count_template
      score = np.zeros((len(p1),))  # save cosine distance between pairs
      total_pairs = np.array(range(len(p1)))
      batchsize = 100000  # small batchsize instead of all pairs in one batch due to the memory limiation
      sublists = [
          total_pairs[i : i + batchsize]
          for i in range(0, len(p1), batchsize)
      ]
      total_sublists = len(sublists)
      for c, s in enumerate(sublists):
          feat1 = template_norm_feats[template2id[p1[s]]]
          feat2 = template_norm_feats[template2id[p2[s]]]
          similarity_score = np.sum(feat1 * feat2, -1)
          score[s] = similarity_score.flatten()
          if c % 10 == 0:
              print("Finish {}/{} pairs.".format(c, total_sublists))
      return score
  
imports: import os
  import pickle
  import matplotlib
  import pandas
  import matplotlib.pyplot
  import timeit
  import sklearn
  import argparse
  from sklearn.metrics import roc_curve, auc
  from menpo.visualize.viewmatplotlib import sample_colours_from_colourmap
  from prettytable import PrettyTable
  from pathlib import Path
  import sys
  import warnings
  import cv2
  import numpy
  import torch
  from skimage import transform
  import backbones
label_desc: Use image node_id 8 for calling a global function with example usage: verification2(template_norm_feats, unique_templates, p1, p2) and returns: score