code: def _generate_topic_models(ensemble, num_models, random_states=None):
      """Train the topic models that form the ensemble.
  
      Parameters
      ----------
      ensemble: EnsembleLda
          the ensemble
      num_models : int
          number of models to be generated
      random_states : list
          list of numbers or np.random.RandomState objects. Will be autogenerated based on the ensembles
          RandomState if None (default).
      """
      if random_states is None:
          random_states = [
              ensemble.random_state.randint(_MAX_RANDOM_STATE)
              for _ in range(num_models)
          ]
  
      assert len(random_states) == num_models
  
      kwargs = ensemble.gensim_kw_args.copy()
  
      tm = None  # remember one of the topic models from the following
      # loop, in order to collect some properties from it afterwards.
  
      for i in range(num_models):
          kwargs["random_state"] = random_states[i]
  
          tm = ensemble.get_topic_model_class()(**kwargs)
  
          # adds the lambda (that is the unnormalized get_topics) to ttda, which is
          # a list of all those lambdas
          ensemble.ttda = np.concatenate(
              [ensemble.ttda, tm.get_topics()]
          )
  
          # only saves the model if it is not "memory friendly"
          if not ensemble.memory_friendly_ttda:
              ensemble.tms += [tm]
  
      # use one of the tms to get some info that will be needed later
      ensemble.sstats_sum = tm.state.sstats.sum()
      ensemble.eta = tm.eta
  
imports: import logging
  import os
  from multiprocessing import Process, Pipe, ProcessError
  import importlib
  from typing import Set, Optional, List
  import numpy
  from scipy.spatial.distance import cosine
  from dataclasses import dataclass
  from gensim import utils
  from gensim.models import ldamodel, ldamulticore, basemodel
  from gensim.utils import SaveLoad
label_desc: Use image node_id 11 for calling a global function with example usage: _generate_topic_models(ensemble, num_models, random_states) without return types