class_docstr: Rank documents according to input strings.
  
  Args:
      vectorizer: a vectorizer class
      top_n: a number of doc ids to return
      active: whether to return a number specified by :attr:`top_n` (``True``) or all ids
       (``False``)
  
  Attributes:
      top_n: a number of doc ids to return
      vectorizer: an instance of vectorizer class
      active: whether to return a number specified by :attr:`top_n` or all ids
      index2doc: inverted :attr:`doc_index`
      iterator: a dataset iterator used for generating batches while fitting the vectorizer
docstr: Rank documents and return top n document titles with scores.
  
  Args:
      questions: list of queries used in ranking
  
  Returns:
      a tuple of selected doc ids and their scores
docstr_tok: ["Rank","documents","and","return","top","n","document","titles","with","scores",".","Args",":","questions",":","list","of","queries","used","in","ranking","Returns",":","a","tuple","of","selected","doc","ids","and","their","scores"]
code: def __call__(
      self, questions: List[str]
  ) -> Tuple[List[Any], List[float]]:
      """Rank documents and return top n document titles with scores.
  
      Args:
          questions: list of queries used in ranking
  
      Returns:
          a tuple of selected doc ids and their scores
      """
  
      batch_doc_ids, batch_docs_scores = [], []
      q_tfidfs = self.vectorizer(questions)
  
      for q_tfidf in q_tfidfs:
          scores = q_tfidf * self.vectorizer.tfidf_matrix
          scores = np.squeeze(
              scores.toarray() + 0.0001
          )  # add a small value to eliminate zero scores
  
          if self.active:
              thresh = self.top_n
          else:
              thresh = len(self.vectorizer.doc_index)
  
          if thresh >= len(scores):
              o = np.argpartition(-scores, len(scores) - 1)[0:thresh]
          else:
              o = np.argpartition(-scores, thresh)[0:thresh]
          o_sort = o[np.argsort(-scores[o])]
  
          doc_scores = scores[o_sort]
          doc_ids = [
              self.vectorizer.index2doc.get(i, int(i)) for i in o_sort
          ]
          batch_doc_ids.append(doc_ids)
          batch_docs_scores.append(doc_scores)
  
      return batch_doc_ids, batch_docs_scores
  
file_path: DeepPavlov/deeppavlov/models/doc_retrieval/tfidf_ranker.py
imports: from logging import getLogger
  from typing import List, Any, Tuple
  import numpy
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.models.estimator import Component
  from deeppavlov.models.vectorizers.hashing_tfidf_vectorizer import HashingTfIdfVectorizer
label_desc: Use image node_id 2 for calling the TfidfRanker obj's underlying member method code with example usage: obj.__call__(questions) and returns: batch_doc_ids,  batch_docs_scores