class_docstr: Static Faiss Retrieval Flask resource.
  The PUT method is to get KNN tokens.
code: def get_knn(
      self, query: Union[List[str], str, torch.Tensor], neighbors: int
  ):
      if neighbors == 0:
          # use padding
          return np.repeat(self.no_retrieval, len(query), 0).astype(
              np.int64
          )
      single_sentence = False
      if isinstance(query, str):
          single_sentence = True
          query = [query]
      elif isinstance(query, torch.Tensor):
          sentence_list = []
          for q in query:
              text = self.tokenizer.ids_to_text(q)
              sentence_list.append(text)
          query = sentence_list
      emb = request_data(
          query, self.query_bert_ip, self.query_bert_port
      )
      emb_data = base64.b64decode(emb.encode())
      emb = pickle.loads(emb_data)
      if self.index.ntotal == 0:
          # A workaround to fix searching an empty Faiss index
          knn = [[-1] * neighbors for i in range(len(emb))]
      else:
          _, knn = self.index.search(emb, neighbors)
      results = []
      for sentence_neighbors in knn:
          chunks = []
          for neighbor_chunk_id in sentence_neighbors:
              chunk_id = self.ds.get_chunk(neighbor_chunk_id)
              chunks.append(chunk_id)
          chunks = np.stack(chunks, axis=0).astype(np.int64)
          results.append(chunks)
      if single_sentence:
          # unpack the single sentence input
          return results[0]
      return np.stack(results, axis=0).astype(np.int64)
  
imports: import base64
  import logging
  import pickle
  import threading
  import time
  from typing import List, Union
  import faiss
  import numpy
  import torch
  from flask import Flask, jsonify, request
  from flask_restful import Api, Resource
  from nemo.collections.common.tokenizers.tokenizer_spec import TokenizerSpec
  from nemo.collections.nlp.data.language_modeling.megatron.indexed_retrieval_dataset import MMapRetrievalIndexedDataset
  from nemo.collections.nlp.modules.common.megatron.retrieval_services.util import lock, request_data
label_desc: Use image node_id 3 for calling the FaissRetrievalResource obj's underlying member method code with example usage: obj.get_knn(query, neighbors) and returns: np, np, results