code: def _generate_topic_models_worker(
      ensemble, num_models, random_states, pipe
  ):
      """Wrapper for _generate_topic_models to write the results into a pipe.
  
      This is intended to be used inside a subprocess."""
      #
      # Same as _generate_topic_models, but runs in a separate subprocess, and
      # sends the updated ensemble state to the parent subprocess via a pipe.
      #
      logger.info(
          f"spawned worker to generate {num_models} topic models"
      )
  
      _generate_topic_models(
          ensemble=ensemble,
          num_models=num_models,
          random_states=random_states,
      )
  
      # send the ttda that is in the child/workers version of the memory into the pipe
      # available, after _generate_topic_models has been called in the worker
      if ensemble.memory_friendly_ttda:
          # remember that this code is inside the worker processes memory,
          # so self.ttda is the ttda of only a chunk of models
          pipe.send(ensemble.ttda)
      else:
          pipe.send(ensemble.tms)
  
      pipe.close()
  
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 12 for calling a global function with example usage: _generate_topic_models_worker(ensemble, num_models, random_states, pipe) without return types