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: Save the model to a file.
  
  Large internal arrays may be stored into separate files, with `fname` as prefix.
  
  Notes
  -----
  If you intend to use models across Python 2/3 versions there are a few things to
  keep in mind:
  
    1. The pickled Python dictionaries will not work across Python versions
    2. The `save` method does not automatically save all numpy arrays separately, only
       those ones that exceed `sep_limit` set in :meth:`~gensim.utils.SaveLoad.save`. The main
       concern here is the `alpha` array if for instance using `alpha='auto'`.
  
  Please refer to the `wiki recipes section
  <https://github.com/RaRe-Technologies/gensim/wiki/
  Recipes-&-FAQ#q9-how-do-i-load-a-model-in-python-3-that-was-trained-and-saved-using-python-2>`_
  for an example on how to work around these issues.
  
  See Also
  --------
  :meth:`~gensim.models.ldamodel.LdaModel.load`
      Load model.
  
  Parameters
  ----------
  fname : str
      Path to the system file where the model will be persisted.
  ignore : tuple of str, optional
      The named attributes in the tuple will be left out of the pickled model. The reason why
      the internal `state` is ignored by default is that it uses its own serialisation rather than the one
      provided by this method.
  separately : {list of str, None}, optional
      If None -  automatically detect large numpy/scipy.sparse arrays in the object being stored, and store
      them into separate files. This avoids pickle memory errors and allows `mmap`'ing large arrays
      back on load efficiently. If list of str - this attributes will be stored in separate files,
      the automatic check is not performed in this case.
  *args
      Positional arguments propagated to :meth:`~gensim.utils.SaveLoad.save`.
  **kwargs
      Key word arguments propagated to :meth:`~gensim.utils.SaveLoad.save`.
docstr_tok: ["Save","the","model","to","a","file",".","Large","internal","arrays","may","be","stored","into","separate","files",",","with","`","fname","`","as","prefix",".","Notes","--","--","-","If","you","intend","to","use","models","across","Python","2\/3","versions","there","are","a","few","things","to","keep","in","mind",":","1",".","The","pickled","Python","dictionaries","will","not","work","across","Python","versions","2",".","The","`","save","`","method","does","not","automatically","save","all","numpy","arrays","separately",",","only","those","ones","that","exceed","`","sep_limit","`","set","in",":","meth",":","`","~gensim.utils.SaveLoad.save","`",".","The","main","concern","here","is","the","`","alpha","`","array","if","for","instance","using","`","alpha='auto","'","`",".","Please","refer","to","the","`","wiki","recipes","section","<","https",":","\/\/github.com\/RaRe-Technologies\/gensim\/wiki\/","Recipes-","&","-FAQ","#","q9-how-do-i-load-a-model-in-python-3-that-was-trained-and-saved-using-python-2",">","`","_","for","an","example","on","how","to","work","around","these","issues",".","See","Also","--","--","--","--",":","meth",":","`","~gensim.models.ldamodel.LdaModel.load","`","Load","model",".","Parameters","--","--","--","--","--","fname",":","str","Path","to","the","system","file","where","the","model","will","be","persisted",".","ignore",":","tuple","of","str",",","optional","The","named","attributes","in","the","tuple","will","be","left","out","of","the","pickled","model",".","The","reason","why","the","internal","`","state","`","is","ignored","by","default","is","that","it","uses","its","own","serialisation","rather","than","the","one","provided","by","this","method",".","separately",":","{","list","of","str",",","None","}",",","optional","If","None","-","automatically","detect","large","numpy\/scipy.sparse","arrays","in","the","object","being","stored",",","and","store","them","into","separate","files",".","This","avoids","pickle","memory","errors","and","allows","`","mmap","`","'ing","large","arrays","back","on","load","efficiently",".","If","list","of","str","-","this","attributes","will","be","stored","in","separate","files",",","the","automatic","check","is","not","performed","in","this","case",".","*","args","Positional","arguments","propagated","to",":","meth",":","`","~gensim.utils.SaveLoad.save","`",".","*","*","kwargs","Key","word","arguments","propagated","to",":","meth",":","`","~gensim.utils.SaveLoad.save","`","."]
code: def save(
      self,
      fname,
      ignore=("state", "dispatcher"),
      separately=None,
      *args,
      **kwargs,
  ):
      """Save the model to a file.
  
      Large internal arrays may be stored into separate files, with `fname` as prefix.
  
      Notes
      -----
      If you intend to use models across Python 2/3 versions there are a few things to
      keep in mind:
  
        1. The pickled Python dictionaries will not work across Python versions
        2. The `save` method does not automatically save all numpy arrays separately, only
           those ones that exceed `sep_limit` set in :meth:`~gensim.utils.SaveLoad.save`. The main
           concern here is the `alpha` array if for instance using `alpha='auto'`.
  
      Please refer to the `wiki recipes section
      <https://github.com/RaRe-Technologies/gensim/wiki/
      Recipes-&-FAQ#q9-how-do-i-load-a-model-in-python-3-that-was-trained-and-saved-using-python-2>`_
      for an example on how to work around these issues.
  
      See Also
      --------
      :meth:`~gensim.models.ldamodel.LdaModel.load`
          Load model.
  
      Parameters
      ----------
      fname : str
          Path to the system file where the model will be persisted.
      ignore : tuple of str, optional
          The named attributes in the tuple will be left out of the pickled model. The reason why
          the internal `state` is ignored by default is that it uses its own serialisation rather than the one
          provided by this method.
      separately : {list of str, None}, optional
          If None -  automatically detect large numpy/scipy.sparse arrays in the object being stored, and store
          them into separate files. This avoids pickle memory errors and allows `mmap`'ing large arrays
          back on load efficiently. If list of str - this attributes will be stored in separate files,
          the automatic check is not performed in this case.
      *args
          Positional arguments propagated to :meth:`~gensim.utils.SaveLoad.save`.
      **kwargs
          Key word arguments propagated to :meth:`~gensim.utils.SaveLoad.save`.
  
      """
      if self.state is not None:
          self.state.save(
              utils.smart_extension(fname, ".state"), *args, **kwargs
          )
      # Save the dictionary separately if not in 'ignore'.
      if "id2word" not in ignore:
          utils.pickle(
              self.id2word, utils.smart_extension(fname, ".id2word")
          )
  
      # make sure 'state', 'id2word' and 'dispatcher' are ignored from the pickled object, even if
      # someone sets the ignore list themselves
      if ignore is not None and ignore:
          if isinstance(ignore, str):
              ignore = [ignore]
          ignore = [
              e for e in ignore if e
          ]  # make sure None and '' are not in the list
          ignore = list(
              {"state", "dispatcher", "id2word"} | set(ignore)
          )
      else:
          ignore = ["state", "dispatcher", "id2word"]
  
      # make sure 'expElogbeta' and 'sstats' are ignored from the pickled object, even if
      # someone sets the separately list themselves.
      separately_explicit = ["expElogbeta", "sstats"]
      # Also add 'alpha' and 'eta' to separately list if they are set 'auto' or some
      # array manually.
      if (isinstance(self.alpha, str) and self.alpha == "auto") or (
          isinstance(self.alpha, np.ndarray)
          and len(self.alpha.shape) != 1
      ):
          separately_explicit.append("alpha")
      if (isinstance(self.eta, str) and self.eta == "auto") or (
          isinstance(self.eta, np.ndarray) and len(self.eta.shape) != 1
      ):
          separately_explicit.append("eta")
      # Merge separately_explicit with separately.
      if separately:
          if isinstance(separately, str):
              separately = [separately]
          separately = [
              e for e in separately if e
          ]  # make sure None and '' are not in the list
          separately = list(set(separately_explicit) | set(separately))
      else:
          separately = separately_explicit
      super(LdaModel, self).save(
          fname, ignore=ignore, separately=separately, *args, **kwargs
      )
  
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 23 for calling the LdaModel obj's underlying member method code with example usage: obj.save(fname, ignore, separately) without return types