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 topic distribution for the given document.
  
  Parameters
  ----------
  bow : corpus : list of (int, float)
      The document in BOW format.
  minimum_probability : float
      Topics with an assigned probability lower than this threshold will be discarded.
  minimum_phi_value : float
      If `per_word_topics` is True, this represents a lower bound on the term probabilities that are included.
       If set to None, a value of 1e-8 is used to prevent 0s.
  per_word_topics : bool
      If True, this function will also return two extra lists as explained in the "Returns" section.
  
  Returns
  -------
  list of (int, float)
      Topic distribution for the whole document. Each element in the list is a pair of a topic's id, and
      the probability that was assigned to it.
  list of (int, list of (int, float), optional
      Most probable topics per word. Each element in the list is a pair of a word's id, and a list of
      topics sorted by their relevance to this word. Only returned if `per_word_topics` was set to True.
  list of (int, list of float), optional
      Phi relevance values, multiplied by the feature length, for each word-topic combination.
      Each element in the list is a pair of a word's id and a list of the phi values between this word and
      each topic. Only returned if `per_word_topics` was set to True.
docstr_tok: ["Get","the","topic","distribution","for","the","given","document",".","Parameters","--","--","--","--","--","bow",":","corpus",":","list","of","(","int",",","float",")","The","document","in","BOW","format",".","minimum_probability",":","float","Topics","with","an","assigned","probability","lower","than","this","threshold","will","be","discarded",".","minimum_phi_value",":","float","If","`","per_word_topics","`","is","True",",","this","represents","a","lower","bound","on","the","term","probabilities","that","are","included",".","If","set","to","None",",","a","value","of","1e-8","is","used","to","prevent","0s",".","per_word_topics",":","bool","If","True",",","this","function","will","also","return","two","extra","lists","as","explained","in","the","``","Returns","''","section",".","Returns","--","--","--","-","list","of","(","int",",","float",")","Topic","distribution","for","the","whole","document",".","Each","element","in","the","list","is","a","pair","of","a","topic","'s","id",",","and","the","probability","that","was","assigned","to","it",".","list","of","(","int",",","list","of","(","int",",","float",")",",","optional","Most","probable","topics","per","word",".","Each","element","in","the","list","is","a","pair","of","a","word","'s","id",",","and","a","list","of","topics","sorted","by","their","relevance","to","this","word",".","Only","returned","if","`","per_word_topics","`","was","set","to","True",".","list","of","(","int",",","list","of","float",")",",","optional","Phi","relevance","values",",","multiplied","by","the","feature","length",",","for","each","word-topic","combination",".","Each","element","in","the","list","is","a","pair","of","a","word","'s","id","and","a","list","of","the","phi","values","between","this","word","and","each","topic",".","Only","returned","if","`","per_word_topics","`","was","set","to","True","."]
code: def get_document_topics(
      self,
      bow,
      minimum_probability=None,
      minimum_phi_value=None,
      per_word_topics=False,
  ):
      """Get the topic distribution for the given document.
  
      Parameters
      ----------
      bow : corpus : list of (int, float)
          The document in BOW format.
      minimum_probability : float
          Topics with an assigned probability lower than this threshold will be discarded.
      minimum_phi_value : float
          If `per_word_topics` is True, this represents a lower bound on the term probabilities that are included.
           If set to None, a value of 1e-8 is used to prevent 0s.
      per_word_topics : bool
          If True, this function will also return two extra lists as explained in the "Returns" section.
  
      Returns
      -------
      list of (int, float)
          Topic distribution for the whole document. Each element in the list is a pair of a topic's id, and
          the probability that was assigned to it.
      list of (int, list of (int, float), optional
          Most probable topics per word. Each element in the list is a pair of a word's id, and a list of
          topics sorted by their relevance to this word. Only returned if `per_word_topics` was set to True.
      list of (int, list of float), optional
          Phi relevance values, multiplied by the feature length, for each word-topic combination.
          Each element in the list is a pair of a word's id and a list of the phi values between this word and
          each topic. Only returned if `per_word_topics` was set to True.
  
      """
      if minimum_probability is None:
          minimum_probability = self.minimum_probability
      minimum_probability = max(
          minimum_probability, 1e-8
      )  # never allow zero values in sparse output
  
      if minimum_phi_value is None:
          minimum_phi_value = self.minimum_probability
      minimum_phi_value = max(
          minimum_phi_value, 1e-8
      )  # never allow zero values in sparse output
  
      # if the input vector is a corpus, return a transformed corpus
      is_corpus, corpus = utils.is_corpus(bow)
      if is_corpus:
          kwargs = dict(
              per_word_topics=per_word_topics,
              minimum_probability=minimum_probability,
              minimum_phi_value=minimum_phi_value,
          )
          return self._apply(corpus, **kwargs)
  
      gamma, phis = self.inference(
          [bow], collect_sstats=per_word_topics
      )
      topic_dist = gamma[0] / sum(gamma[0])  # normalize distribution
  
      document_topics = [
          (topicid, topicvalue)
          for topicid, topicvalue in enumerate(topic_dist)
          if topicvalue >= minimum_probability
      ]
  
      if not per_word_topics:
          return document_topics
  
      word_topic = []  # contains word and corresponding topic
      word_phi = []  # contains word and phi values
      for word_type, weight in bow:
          phi_values = (
              []
          )  # contains (phi_value, topic) pairing to later be sorted
          phi_topic = (
              []
          )  # contains topic and corresponding phi value to be returned 'raw' to user
          for topic_id in range(0, self.num_topics):
              if phis[topic_id][word_type] >= minimum_phi_value:
                  # appends phi values for each topic for that word
                  # these phi values are scaled by feature length
                  phi_values.append(
                      (phis[topic_id][word_type], topic_id)
                  )
                  phi_topic.append(
                      (topic_id, phis[topic_id][word_type])
                  )
  
          # list with ({word_id => [(topic_0, phi_value), (topic_1, phi_value) ...]).
          word_phi.append((word_type, phi_topic))
          # sorts the topics based on most likely topic
          # returns a list like ({word_id => [topic_id_most_probable, topic_id_second_most_probable, ...]).
          sorted_phi_values = sorted(phi_values, reverse=True)
          topics_sorted = [x[1] for x in sorted_phi_values]
          word_topic.append((word_type, topics_sorted))
  
      return document_topics, word_topic, word_phi
  
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 19 for calling the LdaModel obj's underlying member method code with example usage: obj.get_document_topics(bow, minimum_probability, minimum_phi_value, per_word_topics) and returns: document_topics,  word_topic,  word_phi, self, document_topics