code: def unique_ids_from_segments(segmented_topics):
      """Return the set of all unique ids in a list of segmented topics.
  
      Parameters
      ----------
      segmented_topics: list of (int, int).
          Each tuple (word_id_set1, word_id_set2) is either a single integer, or a `numpy.ndarray` of integers.
  
      Returns
      -------
      set
          Set of unique ids across all topic segments.
  
      Example
      -------
      .. sourcecode:: pycon
  
          >>> from gensim.topic_coherence import probability_estimation
          >>>
          >>> segmentation = [[(1, 2)]]
          >>> probability_estimation.unique_ids_from_segments(segmentation)
          set([1, 2])
  
      """
      unique_ids = (
          set()
      )  # is a set of all the unique ids contained in topics.
      for s_i in segmented_topics:
          for word_id in itertools.chain.from_iterable(s_i):
              if hasattr(word_id, "__iter__"):
                  unique_ids.update(word_id)
              else:
                  unique_ids.add(word_id)
  
      return unique_ids
  
imports: import itertools
  import logging
  from gensim.topic_coherence.text_analysis import CorpusAccumulator, WordOccurrenceAccumulator, ParallelWordOccurrenceAccumulator, WordVectorsAccumulator
label_desc: Use image node_id 4 for calling a global function with example usage: unique_ids_from_segments(segmented_topics) and returns: unique_ids