class_docstr: Loads a pre-weighted inverted index of token/document terms.
  
  Scores new queries by taking sparse dot products.
docstr: Closest docs by dot product between query and documents in tfidf weighted word
  vector space.
  
  matrix arg can be provided to be used instead of internal doc matrix.
code: def closest_docs(self, query, k=1, matrix=None):
      """
      Closest docs by dot product between query and documents in tfidf weighted word
      vector space.
  
      matrix arg can be provided to be used instead of internal doc matrix.
      """
      spvec = self.text2spvec(query)
      res = (
          spvec * matrix if matrix is not None else spvec * self.doc_mat
      )
  
      if len(res.data) <= k:
          o_sort = np.argsort(-res.data)
      else:
          o = np.argpartition(-res.data, k)[0:k]
          o_sort = o[np.argsort(-res.data[o])]
  
      doc_scores = res.data[o_sort]
      doc_ids = res.indices[o_sort]
      return doc_ids, doc_scores
  
file_path: ParlAI/parlai/agents/tfidf_retriever/tfidf_doc_ranker.py
imports: import numpy
  import scipy.sparse
  from .None import utils
  from .None import tokenizers
  from parlai.utils.logging import logger
label_desc: Use image node_id 3 for calling the TfidfDocRanker obj's underlying member method code with example usage: obj.closest_docs(query, k, matrix) and returns: doc_ids,  doc_scores