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 a representation for selected topics.
  
  Parameters
  ----------
  num_topics : int, optional
      Number of topics to be returned. Unlike LSA, there is no natural ordering between the topics in LDA.
      The returned topics subset of all topics is therefore arbitrary and may change between two LDA
      training runs.
  num_words : int, optional
      Number of words to be presented for each topic. These will be the most relevant words (assigned the highest
      probability for each topic).
  log : bool, optional
      Whether the output is also logged, besides being returned.
  formatted : bool, optional
      Whether the topic representations should be formatted as strings. If False, they are returned as
      2 tuples of (word, probability).
  
  Returns
  -------
  list of {str, tuple of (str, float)}
      a list of topics, each represented either as a string (when `formatted` == True) or word-probability
      pairs.
docstr_tok: ["Get","a","representation","for","selected","topics",".","Parameters","--","--","--","--","--","num_topics",":","int",",","optional","Number","of","topics","to","be","returned",".","Unlike","LSA",",","there","is","no","natural","ordering","between","the","topics","in","LDA",".","The","returned","topics","subset","of","all","topics","is","therefore","arbitrary","and","may","change","between","two","LDA","training","runs",".","num_words",":","int",",","optional","Number","of","words","to","be","presented","for","each","topic",".","These","will","be","the","most","relevant","words","(","assigned","the","highest","probability","for","each","topic",")",".","log",":","bool",",","optional","Whether","the","output","is","also","logged",",","besides","being","returned",".","formatted",":","bool",",","optional","Whether","the","topic","representations","should","be","formatted","as","strings",".","If","False",",","they","are","returned","as","2","tuples","of","(","word",",","probability",")",".","Returns","--","--","--","-","list","of","{","str",",","tuple","of","(","str",",","float",")","}","a","list","of","topics",",","each","represented","either","as","a","string","(","when","`","formatted","`","==","True",")","or","word-probability","pairs","."]
code: def show_topics(
      self, num_topics=10, num_words=10, log=False, formatted=True
  ):
      """Get a representation for selected topics.
  
      Parameters
      ----------
      num_topics : int, optional
          Number of topics to be returned. Unlike LSA, there is no natural ordering between the topics in LDA.
          The returned topics subset of all topics is therefore arbitrary and may change between two LDA
          training runs.
      num_words : int, optional
          Number of words to be presented for each topic. These will be the most relevant words (assigned the highest
          probability for each topic).
      log : bool, optional
          Whether the output is also logged, besides being returned.
      formatted : bool, optional
          Whether the topic representations should be formatted as strings. If False, they are returned as
          2 tuples of (word, probability).
  
      Returns
      -------
      list of {str, tuple of (str, float)}
          a list of topics, each represented either as a string (when `formatted` == True) or word-probability
          pairs.
  
      """
      if num_topics < 0 or num_topics >= self.num_topics:
          num_topics = self.num_topics
          chosen_topics = range(num_topics)
      else:
          num_topics = min(num_topics, self.num_topics)
  
          # add a little random jitter, to randomize results around the same alpha
          sort_alpha = self.alpha + 0.0001 * self.random_state.rand(
              len(self.alpha)
          )
          # random_state.rand returns float64, but converting back to dtype won't speed up anything
  
          sorted_topics = list(matutils.argsort(sort_alpha))
          chosen_topics = (
              sorted_topics[: num_topics // 2]
              + sorted_topics[-num_topics // 2 :]
          )
  
      shown = []
  
      topic = self.state.get_lambda()
      for i in chosen_topics:
          topic_ = topic[i]
          topic_ = (
              topic_ / topic_.sum()
          )  # normalize to probability distribution
          bestn = matutils.argsort(topic_, num_words, reverse=True)
          topic_ = [(self.id2word[id], topic_[id]) for id in bestn]
          if formatted:
              topic_ = " + ".join(
                  '%.3f*"%s"' % (v, k) for k, v in topic_
              )
  
          shown.append((i, topic_))
          if log:
              logger.info(
                  "topic #%i (%.3f): %s", i, self.alpha[i], topic_
              )
  
      return shown
  
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 14 for calling the LdaModel obj's underlying member method code with example usage: obj.show_topics(num_topics, num_words, log, formatted) and returns: shown