code: def find_nearest_neighbor(query, vectors, ban_set, cossims=None):
      """
      query is a 1d numpy array corresponding to the vector to which you want to
      find the closest vector
      vectors is a 2d numpy array corresponding to the vectors you want to consider
      ban_set is a set of indicies within vectors you want to ignore for nearest match
      cossims is a 1d numpy array of size len(vectors), which can be passed for efficiency
  
      returns the index of the closest match to query within vectors
  
      """
      if cossims is None:
          cossims = np.matmul(vectors, query, out=cossims)
      else:
          np.matmul(vectors, query, out=cossims)
      rank = len(cossims) - 1
      result_i = np.argpartition(cossims, rank)[rank]
      while result_i in ban_set:
          rank -= 1
          result_i = np.argpartition(cossims, rank)[rank]
      return result_i
  
file_path: fastText/python/fasttext_module/fasttext/util/util.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import numpy
  import sys
  import shutil
  import os
  import gzip
label_desc: Use image node_id 2 for calling a global function with example usage: find_nearest_neighbor(query, vectors, ban_set, cossims) and returns: result_i