class_docstr: Dynamic Faiss Retrieval Flask resource.
  The PUT method is to get KNN tokens, add new chunks, reset index.
docstr: Add documents to the Faiss index
  Args:
      docs: List[str], list of documents that is going to be added to the index
      add_eos: bool, whether add the eos in the end
docstr_tok: ["Add","documents","to","the","Faiss","index","Args",":","docs",":","List","[","str","]",",","list","of","documents","that","is","going","to","be","added","to","the","index","add_eos",":","bool",",","whether","add","the","eos","in","the","end"]
code: def add_docs_to_index(self, docs: List[str], add_eos: bool = True):
      """
      Add documents to the Faiss index
      Args:
          docs: List[str], list of documents that is going to be added to the index
          add_eos: bool, whether add the eos in the end
      """
      for doc in docs:
          token_ids = self.tokenizer.text_to_ids(doc)
          # append eos in the end
          if add_eos:
              token_ids.append(self.tokenizer.eos_id)
          np_array = np.array(token_ids, dtype=np.int32)
          padded_size = self.chunk_size - (
              len(np_array) % self.chunk_size
          )
          # for retrieval database, added one more chunk in the end as padding
          padded_size += self.chunk_size
          np_array = np.pad(
              np_array,
              (0, padded_size),
              "constant",
              constant_values=self.pad_id,
          )
          chunk_texts = []
          for i in range(0, len(np_array), self.stride):
              if i + 2 * self.chunk_size <= len(np_array):
                  chunk = np_array[i : i + 2 * self.chunk_size]
                  self.ds.add(chunk)
                  chunk_texts.append(self.tokenizer.ids_to_text(chunk))
          emb = request_data(
              chunk_texts, self.ctx_bert_ip, self.ctx_bert_port
          )
          emb_data = base64.b64decode(emb.encode())
          emb = pickle.loads(emb_data)
          self.index.add(emb)
  
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 4 for calling the DynamicRetrievalResource obj's underlying member method code with example usage: obj.add_docs_to_index(docs, add_eos) without return types