docstr: Rank documents by topic score.
  If topic_index is supplied, rank documents based on relevance to supplied topic.
  Otherwise, rank all texts by their highest topic score (for any topic).
  Args:
      texts(list of str): list of document texts.
      doc_topics(ndarray): pre-computed topic distribution for each document
                           If None, re-computed from texts.
  
  Returns:
      dict of lists: each element in list is a tuple of (doc_index, topic_index, score)
      ... where doc_index is an index into either texts
docstr_tok: ["Rank","documents","by","topic","score",".","If","topic_index","is","supplied",",","rank","documents","based","on","relevance","to","supplied","topic",".","Otherwise",",","rank","all","texts","by","their","highest","topic","score","(","for","any","topic",")",".","Args",":","texts","(","list","of","str",")",":","list","of","document","texts",".","doc_topics","(","ndarray",")",":","pre-computed","topic","distribution","for","each","document","If","None",",","re-computed","from","texts",".","Returns",":","dict","of","lists",":","each","element","in","list","is","a","tuple","of","(","doc_index",",","topic_index",",","score",")","...","where","doc_index","is","an","index","into","either","texts"]
code: def _rank_documents(self, texts, doc_topics=None):
      """
      Rank documents by topic score.
      If topic_index is supplied, rank documents based on relevance to supplied topic.
      Otherwise, rank all texts by their highest topic score (for any topic).
      Args:
          texts(list of str): list of document texts.
          doc_topics(ndarray): pre-computed topic distribution for each document
                               If None, re-computed from texts.
  
      Returns:
          dict of lists: each element in list is a tuple of (doc_index, topic_index, score)
          ... where doc_index is an index into either texts
      """
      if doc_topics is not None:
          X_topics = doc_topics
      else:
          if self.verbose:
              print("transforming texts to topic space...")
          X_topics = self.predict(texts)
      topics = np.argmax(X_topics, axis=1)
      scores = np.amax(X_topics, axis=1)
      doc_ids = np.array([i for i, x in enumerate(texts)])
      result = list(zip(texts, doc_ids, topics, scores))
      if self.verbose:
          print("done.")
      result = sorted(result, key=lambda x: x[-1], reverse=True)
      result_dict = {}
      for r in result:
          text = r[0]
          doc_id = r[1]
          topic_id = r[2]
          score = r[3]
          lst = result_dict.get(topic_id, [])
          lst.append((text, doc_id, score))
          result_dict[topic_id] = lst
      return result_dict
  
imports: import time
  from ..None import utils
  from ..imports import *
  from .None import preprocessor
  from .None import textutils
label_desc: Use image node_id 21 for calling the TopicModel obj's underlying member method code with example usage: obj._rank_documents(texts, doc_topics) and returns: result_dict