class_docstr: Objects of this class allow for building and maintaining a model for topic coherence.
  
  Examples
  ---------
  One way of using this feature is through providing a trained topic model. A dictionary has to be explicitly provided
  if the model does not contain a dictionary already
  
  .. sourcecode:: pycon
  
      >>> from gensim.test.utils import common_corpus, common_dictionary
      >>> from gensim.models.ldamodel import LdaModel
      >>> from gensim.models.coherencemodel import CoherenceModel
      >>>
      >>> model = LdaModel(common_corpus, 5, common_dictionary)
      >>>
      >>> cm = CoherenceModel(model=model, corpus=common_corpus, coherence='u_mass')
      >>> coherence = cm.get_coherence()  # get coherence value
  
  Another way of using this feature is through providing tokenized topics such as:
  
  .. sourcecode:: pycon
  
      >>> from gensim.test.utils import common_corpus, common_dictionary
      >>> from gensim.models.coherencemodel import CoherenceModel
      >>> topics = [
      ...     ['human', 'computer', 'system', 'interface'],
      ...     ['graph', 'minors', 'trees', 'eps']
      ... ]
      >>>
      >>> cm = CoherenceModel(topics=topics, corpus=common_corpus, dictionary=common_dictionary, coherence='u_mass')
      >>> coherence = cm.get_coherence()  # get coherence value
class_docstr_tok: ["Objects","of","this","class","allow","for","building","and","maintaining","a","model","for","topic","coherence",".","Examples","--","--","--","--","-","One","way","of","using","this","feature","is","through","providing","a","trained","topic","model",".","A","dictionary","has","to","be","explicitly","provided","if","the","model","does","not","contain","a","dictionary","already","..","sourcecode",":",":","pycon",">",">",">","from","gensim.test.utils","import","common_corpus",",","common_dictionary",">",">",">","from","gensim.models.ldamodel","import","LdaModel",">",">",">","from","gensim.models.coherencemodel","import","CoherenceModel",">",">",">",">",">",">","model","=","LdaModel","(","common_corpus",",","5",",","common_dictionary",")",">",">",">",">",">",">","cm","=","CoherenceModel","(","model=model",",","corpus=common_corpus",",","coherence='u_mass","'",")",">",">",">","coherence","=","cm.get_coherence","(",")","#","get","coherence","value","Another","way","of","using","this","feature","is","through","providing","tokenized","topics","such","as",":","..","sourcecode",":",":","pycon",">",">",">","from","gensim.test.utils","import","common_corpus",",","common_dictionary",">",">",">","from","gensim.models.coherencemodel","import","CoherenceModel",">",">",">","topics","=","[","...","[","'human","'",",","'computer","'",",","'system","'",",","'interface","'","]",",","...","[","'graph","'",",","'minors","'",",","'trees","'",",","'eps","'","]","...","]",">",">",">",">",">",">","cm","=","CoherenceModel","(","topics=topics",",","corpus=common_corpus",",","dictionary=common_dictionary",",","coherence='u_mass","'",")",">",">",">","coherence","=","cm.get_coherence","(",")","#","get","coherence","value"]
docstr: Initialize a CoherenceModel with estimated probabilities for all of the given topics.
  
  Parameters
  ----------
  topics_as_topn_terms : list of list of str
      Each element in the top-level list should be the list of topics for a model.
      The topics for the model should be a list of top-N words, one per topic.
  
  Return
  ------
  :class:`~gensim.models.coherencemodel.CoherenceModel`
      CoherenceModel with estimated probabilities for all of the given models.
docstr_tok: ["Initialize","a","CoherenceModel","with","estimated","probabilities","for","all","of","the","given","topics",".","Parameters","--","--","--","--","--","topics_as_topn_terms",":","list","of","list","of","str","Each","element","in","the","top-level","list","should","be","the","list","of","topics","for","a","model",".","The","topics","for","the","model","should","be","a","list","of","top-N","words",",","one","per","topic",".","Return","--","--","--",":","class",":","`","~gensim.models.coherencemodel.CoherenceModel","`","CoherenceModel","with","estimated","probabilities","for","all","of","the","given","models","."]
code: def for_topics(cls, topics_as_topn_terms, **kwargs):
      """Initialize a CoherenceModel with estimated probabilities for all of the given topics.
  
      Parameters
      ----------
      topics_as_topn_terms : list of list of str
          Each element in the top-level list should be the list of topics for a model.
          The topics for the model should be a list of top-N words, one per topic.
  
      Return
      ------
      :class:`~gensim.models.coherencemodel.CoherenceModel`
          CoherenceModel with estimated probabilities for all of the given models.
  
      """
      if not topics_as_topn_terms:
          raise ValueError("len(topics) must be > 0.")
      if any(
          len(topic_lists) == 0 for topic_lists in topics_as_topn_terms
      ):
          raise ValueError("found empty topic listing in `topics`")
  
      topn = 0
      for topic_list in topics_as_topn_terms:
          for topic in topic_list:
              topn = max(topn, len(topic))
  
      topn = min(kwargs.pop("topn", topn), topn)
      super_topic = utils.flatten(topics_as_topn_terms)
  
      logging.info(
          "Number of relevant terms for all %d models: %d",
          len(topics_as_topn_terms),
          len(super_topic),
      )
      cm = CoherenceModel(
          topics=[super_topic], topn=len(super_topic), **kwargs
      )
      cm.estimate_probabilities()
      cm.topn = topn
      return cm
  
imports: import logging
  import multiprocessing
  from collections import namedtuple
  import numpy
  from gensim import interfaces, matutils
  from gensim import utils
  from gensim.topic_coherence import segmentation, probability_estimation, direct_confirmation_measure, indirect_confirmation_measure, aggregation
  from gensim.topic_coherence.probability_estimation import unique_ids_from_segments
label_desc: Use image node_id 4 for calling the CoherenceModel obj's underlying member method code with example usage: obj.for_topics(cls, topics_as_topn_terms) and returns: cm