code: def __init__(
      self,
      feats,
      k,
      nprobe=128,
      omp_num_threads=None,
      rebuild_index=True,
      verbose=True,
      **kwargs,
  ):
      import faiss
  
      if omp_num_threads is not None:
          faiss.omp_set_num_threads(omp_num_threads)
      self.verbose = verbose
      with Timer("[faiss] build index", verbose):
          feats = feats.astype("float32")
          size, dim = feats.shape
          index = faiss.IndexFlatIP(dim)
          index.add(feats)
      with Timer("[faiss] query topk {}".format(k), verbose):
          sims, nbrs = index.search(feats, k=k)
          self.knns = [
              (
                  np.array(nbr, dtype=np.int32),
                  1 - np.array(sim, dtype=np.float32),
              )
              for nbr, sim in zip(nbrs, sims)
          ]
  
file_path: dgl/examples/pytorch/hilander/utils/knn.py
imports: import math
  import multiprocessing
  import os
  import numpy
  from tqdm import tqdm
  from utils import Timer
  from .faiss_search import faiss_search_knn
label_desc: Use image node_id 1 to create a new knn_faiss object from inherited base classes: knn with example: obj = knn_faiss(feats, k, nprobe, omp_num_threads, rebuild_index, verbose)