class_docstr: Dynamic Faiss Retrieval Flask resource.
  The PUT method is to get KNN tokens, add new chunks, reset index.
code: def put(self):
      data = request.get_json()
      if "neighbors" in data:
          sentences = data["sentences"]
          # do knn query
          num_neighbors = data["neighbors"]
          with (
              lock
          ):  # Need to get lock to keep multiple threads from hitting code
              neighbors = self.get_knn(sentences, num_neighbors)
          return jsonify(neighbors.tolist())
      elif "reset" in data:
          with (
              lock
          ):  # Need to get lock to keep multiple threads from hitting code
              self.reset()
          return "success"
      elif "index_name" in data:
          with lock:
              # serialize the index
              index = self.index
              if hasattr(faiss, "index_gpu_to_cpu"):
                  index = faiss.index_gpu_to_cpu(index)
              faiss.write_index(
                  index,
                  data["index_name"]
                  + "_"
                  + self.output_filename
                  + ".index",
              )
              # save the data
              with open(self.output_filename + ".pkl", "bw") as f:
                  pickle.dump(self.ds, f)
              return "success"
      else:
          sentences = data["sentences"]
          add_eos = data["add_eos"]
          # update the index
          with (
              lock
          ):  # Need to get lock to keep multiple threads from hitting code
              self.add_docs_to_index(sentences, add_eos)
          return "success"
  
imports: import base64
  import logging
  import pickle
  import threading
  import time
  from collections import namedtuple
  from typing import List
  import faiss
  import numpy
  import torch
  from flask import Flask, jsonify, request
  from flask_restful import Api
  from nemo.collections.common.tokenizers.tokenizer_spec import TokenizerSpec
  from nemo.collections.nlp.modules.common.megatron.retrieval_services.static_retrieval_server import FaissRetrievalResource
  from nemo.collections.nlp.modules.common.megatron.retrieval_services.util import lock, request_data
label_desc: Use image node_id 2 for calling the DynamicRetrievalResource obj's underlying member method code with example usage: obj.put() and returns: jsonify, str, str, str