class_docstr: An index which can be deserialized from the files built using https://github.com/facebookresearch/DPR. We use
  default faiss index parameters as specified in that repository.
  
  Args:
      vector_size (`int`):
          The dimension of indexed vectors.
      index_path (`str`):
          A path to a *directory* containing index files compatible with [`~models.rag.retrieval_rag.LegacyIndex`]
class_docstr_tok: ["An","index","which","can","be","deserialized","from","the","files","built","using","https",":","\/\/github.com\/facebookresearch\/DPR",".","We","use","default","faiss","index","parameters","as","specified","in","that","repository",".","Args",":","vector_size","(","`","int","`",")",":","The","dimension","of","indexed","vectors",".","index_path","(","`","str","`",")",":","A","path","to","a","*","directory","*","containing","index","files","compatible","with","[","`","~models.rag.retrieval_rag.LegacyIndex","`","]"]
code: def get_top_docs(
      self, question_hidden_states: np.ndarray, n_docs=5
  ) -> Tuple[np.ndarray, np.ndarray]:
      aux_dim = np.zeros(
          len(question_hidden_states), dtype="float32"
      ).reshape(-1, 1)
      query_nhsw_vectors = np.hstack((question_hidden_states, aux_dim))
      _, docs_ids = self.index.search(query_nhsw_vectors, n_docs)
      vectors = [
          [
              self.index.reconstruct(int(doc_id))[:-1]
              for doc_id in doc_ids
          ]
          for doc_ids in docs_ids
      ]
      ids = [
          [int(self.index_id_to_db_id[doc_id]) for doc_id in doc_ids]
          for doc_ids in docs_ids
      ]
      return np.array(ids), np.array(vectors)
  
imports: import os
  import pickle
  import time
  from typing import Iterable, List, Optional, Tuple
  import numpy
  from ...tokenization_utils import PreTrainedTokenizer
  from ...tokenization_utils_base import BatchEncoding
  from ...utils import cached_file, is_datasets_available, is_faiss_available, logging, requires_backends, strtobool
  from .configuration_rag import RagConfig
  from .tokenization_rag import RagTokenizer
label_desc: Use image node_id 8 for calling the LegacyIndex obj's underlying member method code with example usage: obj.get_top_docs(question_hidden_states, n_docs) and returns: np,  np