class_docstr: Train and use Online Latent Dirichlet Allocation model as presented in
  `'Online Learning for LDA' by Hoffman et al.`_
  
  Examples
  -------
  Initialize a model using a Gensim corpus
  
  .. sourcecode:: pycon
  
      >>> from gensim.test.utils import common_corpus
      >>>
      >>> lda = LdaModel(common_corpus, num_topics=10)
  
  You can then infer topic distributions on new, unseen documents.
  
  .. sourcecode:: pycon
  
      >>> doc_bow = [(1, 0.3), (2, 0.1), (0, 0.09)]
      >>> doc_lda = lda[doc_bow]
  
  The model can be updated (trained) with new documents.
  
  .. sourcecode:: pycon
  
      >>> # In practice (corpus =/= initial training corpus), but we use the same here for simplicity.
      >>> other_corpus = common_corpus
      >>>
      >>> lda.update(other_corpus)
  
  Model persistency is achieved through :meth:`~gensim.models.ldamodel.LdaModel.load` and
  :meth:`~gensim.models.ldamodel.LdaModel.save` methods.
class_docstr_tok: ["Train","and","use","Online","Latent","Dirichlet","Allocation","model","as","presented","in","`","'Online","Learning","for","LDA","'","by","Hoffman","et","al.","`","_","Examples","--","--","--","-","Initialize","a","model","using","a","Gensim","corpus","..","sourcecode",":",":","pycon",">",">",">","from","gensim.test.utils","import","common_corpus",">",">",">",">",">",">","lda","=","LdaModel","(","common_corpus",",","num_topics=10",")","You","can","then","infer","topic","distributions","on","new",",","unseen","documents",".","..","sourcecode",":",":","pycon",">",">",">","doc_bow","=","[","(","1",",","0.3",")",",","(","2",",","0.1",")",",","(","0",",","0.09",")","]",">",">",">","doc_lda","=","lda","[","doc_bow","]","The","model","can","be","updated","(","trained",")","with","new","documents",".","..","sourcecode",":",":","pycon",">",">",">","#","In","practice","(","corpus","=\/=","initial","training","corpus",")",",","but","we","use","the","same","here","for","simplicity",".",">",">",">","other_corpus","=","common_corpus",">",">",">",">",">",">","lda.update","(","other_corpus",")","Model","persistency","is","achieved","through",":","meth",":","`","~gensim.models.ldamodel.LdaModel.load","`","and",":","meth",":","`","~gensim.models.ldamodel.LdaModel.save","`","methods","."]
docstr: Get the topics with the highest coherence score the coherence for each topic.
  
  Parameters
  ----------
  corpus : iterable of list of (int, float), optional
      Corpus in BoW format.
  texts : list of list of str, optional
      Tokenized texts, needed for coherence models that use sliding window based (i.e. coherence=`c_something`)
      probability estimator .
  dictionary : :class:`~gensim.corpora.dictionary.Dictionary`, optional
      Gensim dictionary mapping of id word to create corpus.
      If `model.id2word` is present, this is not needed. If both are provided, passed `dictionary` will be used.
  window_size : int, optional
      Is the size of the window to be used for coherence measures using boolean sliding window as their
      probability estimator. For 'u_mass' this doesn't matter.
      If None - the default window sizes are used which are: 'c_v' - 110, 'c_uci' - 10, 'c_npmi' - 10.
  coherence : {'u_mass', 'c_v', 'c_uci', 'c_npmi'}, optional
      Coherence measure to be used.
      Fastest method - 'u_mass', 'c_uci' also known as `c_pmi`.
      For 'u_mass' corpus should be provided, if texts is provided, it will be converted to corpus
      using the dictionary. For 'c_v', 'c_uci' and 'c_npmi' `texts` should be provided (`corpus` isn't needed)
  topn : int, optional
      Integer corresponding to the number of top words to be extracted from each topic.
  processes : int, optional
      Number of processes to use for probability estimation phase, any value less than 1 will be interpreted as
      num_cpus - 1.
  
  Returns
  -------
  list of (list of (int, str), float)
      Each element in the list is a pair of a topic representation and its coherence score. Topic representations
      are distributions of words, represented as a list of pairs of word IDs and their probabilities.
docstr_tok: ["Get","the","topics","with","the","highest","coherence","score","the","coherence","for","each","topic",".","Parameters","--","--","--","--","--","corpus",":","iterable","of","list","of","(","int",",","float",")",",","optional","Corpus","in","BoW","format",".","texts",":","list","of","list","of","str",",","optional","Tokenized","texts",",","needed","for","coherence","models","that","use","sliding","window","based","(","i.e",".","coherence=","`","c_something","`",")","probability","estimator",".","dictionary",":",":","class",":","`","~gensim.corpora.dictionary.Dictionary","`",",","optional","Gensim","dictionary","mapping","of","id","word","to","create","corpus",".","If","`","model.id2word","`","is","present",",","this","is","not","needed",".","If","both","are","provided",",","passed","`","dictionary","`","will","be","used",".","window_size",":","int",",","optional","Is","the","size","of","the","window","to","be","used","for","coherence","measures","using","boolean","sliding","window","as","their","probability","estimator",".","For","'u_mass","'","this","does","n't","matter",".","If","None","-","the","default","window","sizes","are","used","which","are",":","'c_v","'","-","110",",","'c_uci","'","-","10",",","'c_npmi","'","-","10.","coherence",":","{","'u_mass","'",",","'c_v","'",",","'c_uci","'",",","'c_npmi","'","}",",","optional","Coherence","measure","to","be","used",".","Fastest","method","-","'u_mass","'",",","'c_uci","'","also","known","as","`","c_pmi","`",".","For","'u_mass","'","corpus","should","be","provided",",","if","texts","is","provided",",","it","will","be","converted","to","corpus","using","the","dictionary",".","For","'c_v","'",",","'c_uci","'","and","'c_npmi","'","`","texts","`","should","be","provided","(","`","corpus","`","is","n't","needed",")","topn",":","int",",","optional","Integer","corresponding","to","the","number","of","top","words","to","be","extracted","from","each","topic",".","processes",":","int",",","optional","Number","of","processes","to","use","for","probability","estimation","phase",",","any","value","less","than","1","will","be","interpreted","as","num_cpus","-","1",".","Returns","--","--","--","-","list","of","(","list","of","(","int",",","str",")",",","float",")","Each","element","in","the","list","is","a","pair","of","a","topic","representation","and","its","coherence","score",".","Topic","representations","are","distributions","of","words",",","represented","as","a","list","of","pairs","of","word","IDs","and","their","probabilities","."]
code: def top_topics(
      self,
      corpus=None,
      texts=None,
      dictionary=None,
      window_size=None,
      coherence="u_mass",
      topn=20,
      processes=-1,
  ):
      """Get the topics with the highest coherence score the coherence for each topic.
  
      Parameters
      ----------
      corpus : iterable of list of (int, float), optional
          Corpus in BoW format.
      texts : list of list of str, optional
          Tokenized texts, needed for coherence models that use sliding window based (i.e. coherence=`c_something`)
          probability estimator .
      dictionary : :class:`~gensim.corpora.dictionary.Dictionary`, optional
          Gensim dictionary mapping of id word to create corpus.
          If `model.id2word` is present, this is not needed. If both are provided, passed `dictionary` will be used.
      window_size : int, optional
          Is the size of the window to be used for coherence measures using boolean sliding window as their
          probability estimator. For 'u_mass' this doesn't matter.
          If None - the default window sizes are used which are: 'c_v' - 110, 'c_uci' - 10, 'c_npmi' - 10.
      coherence : {'u_mass', 'c_v', 'c_uci', 'c_npmi'}, optional
          Coherence measure to be used.
          Fastest method - 'u_mass', 'c_uci' also known as `c_pmi`.
          For 'u_mass' corpus should be provided, if texts is provided, it will be converted to corpus
          using the dictionary. For 'c_v', 'c_uci' and 'c_npmi' `texts` should be provided (`corpus` isn't needed)
      topn : int, optional
          Integer corresponding to the number of top words to be extracted from each topic.
      processes : int, optional
          Number of processes to use for probability estimation phase, any value less than 1 will be interpreted as
          num_cpus - 1.
  
      Returns
      -------
      list of (list of (int, str), float)
          Each element in the list is a pair of a topic representation and its coherence score. Topic representations
          are distributions of words, represented as a list of pairs of word IDs and their probabilities.
  
      """
      cm = CoherenceModel(
          model=self,
          corpus=corpus,
          texts=texts,
          dictionary=dictionary,
          window_size=window_size,
          coherence=coherence,
          topn=topn,
          processes=processes,
      )
      coherence_scores = cm.get_coherence_per_topic()
  
      str_topics = []
      for (
          topic
      ) in (
          self.get_topics()
      ):  # topic = array of vocab_size floats, one per term
          bestn = matutils.argsort(
              topic, topn=topn, reverse=True
          )  # top terms for topic
          beststr = [
              (topic[_id], self.id2word[_id]) for _id in bestn
          ]  # membership, token
          str_topics.append(
              beststr
          )  # list of topn (float membership, token) tuples
  
      scored_topics = zip(str_topics, coherence_scores)
      return sorted(scored_topics, key=lambda tup: tup[1], reverse=True)
  
imports: import logging
  import numbers
  import os
  import time
  from collections import defaultdict
  import numpy
  from scipy.special import gammaln, psi
  from scipy.special import polygamma
  from gensim import interfaces, utils, matutils
  from gensim.matutils import kullback_leibler, hellinger, jaccard_distance, jensen_shannon, dirichlet_expectation, logsumexp, mean_absolute_difference
  from gensim.models import basemodel, CoherenceModel
  from gensim.models.callbacks import Callback
label_desc: Use image node_id 18 for calling the LdaModel obj's underlying member method code with example usage: obj.top_topics(corpus, texts, dictionary, window_size, coherence, topn, processes) and returns: sorted