code: def kNN(
      x,
      y,
      k,
      use_ann_search=False,
      ann_num_clusters=32768,
      ann_num_cluster_probe=3,
  ):
      start_time = time.time()
      if use_ann_search:
          print("Perform approx. kNN search")
          n_cluster = min(ann_num_clusters, int(y.shape[0] / 1000))
          quantizer = faiss.IndexFlatIP(y.shape[1])
          index = faiss.IndexIVFFlat(
              quantizer,
              y.shape[1],
              n_cluster,
              faiss.METRIC_INNER_PRODUCT,
          )
          index.nprobe = ann_num_cluster_probe
          index.train(y)
          index.add(y)
          sim, ind = index.search(x, k)
      else:
          print("Perform exact search")
          idx = faiss.IndexFlatIP(y.shape[1])
          idx.add(y)
          sim, ind = idx.search(x, k)
  
      print("Done: {:.2f} sec".format(time.time() - start_time))
      return sim, ind
  
file_path: sentence-transformers/examples/applications/parallel-sentence-mining/bitext_mining_utils.py
imports: import faiss
  import numpy
  import time
  import gzip
  import lzma
label_desc: Use image node_id 3 for calling a global function with example usage: kNN(x, y, k, use_ann_search, ann_num_clusters, ann_num_cluster_probe) and returns: sim,  ind