docstr: Build the ensemble
  
  Parameters
  ----------
  dask_client: dask.distributed.Client
      The dask client to use
docstr_tok: ["Build","the","ensemble","Parameters","--","--","--","--","--","dask_client",":","dask.distributed.Client","The","dask","client","to","use"]
code: def build_ensemble(
      self,
      dask_client: dask.distributed.Client,
  ) -> None:
      """Build the ensemble
  
      Parameters
      ----------
      dask_client: dask.distributed.Client
          The dask client to use
      """
      # The second criteria is elapsed time
      elapsed_time = time.time() - self.start_time
  
      logger = get_named_client_logger(
          name="EnsembleBuilder",
          port=self.logger_port,
      )
  
      # First test for termination conditions
      if self.time_left_for_ensembles < elapsed_time:
          logger.info(
              "Terminate ensemble building as not time is left (run for {}s)".format(
                  elapsed_time
              ),
          )
          return
      if (
          self.max_iterations is not None
          and self.max_iterations <= self.iteration
      ):
          logger.info(
              "Terminate ensemble building because of max iterations:"
              f" {self.max_iterations} of {self.iteration}"
          )
          return
  
      if len(self.futures) != 0:
          if self.futures[0].done():
              result = self.futures.pop().result()
              if result:
                  ensemble_history, self.ensemble_nbest = result
                  logger.debug(
                      f"iteration={self.iteration} @ elapsed_time={elapsed_time}"
                      f" has history={ensemble_history}"
                  )
                  self.history.extend(ensemble_history)
  
      # Only submit new jobs if the previous ensemble job finished
      if len(self.futures) == 0:
          # Add the result of the run
          # On the next while iteration, no references to
          # ensemble builder object, so it should be garbage collected to
          # save memory while waiting for resources
          # Also, notice how ensemble nbest is returned, so we don't waste
          # iterations testing if the deterministic predictions size can
          # be fitted in memory
          try:
              # Submit a Dask job from this job, to properly
              # see it in the dask diagnostic dashboard
              # Notice that the forked ensemble_builder_process will
              # wait for the below function to be done
              self.futures.append(
                  dask_client.submit(
                      EnsembleBuilderManager.fit_and_return_ensemble,
                      backend=self.backend,
                      dataset_name=self.dataset_name,
                      task_type=self.task,
                      metrics=self.metrics,
                      ensemble_class=self.ensemble_class,
                      ensemble_kwargs=self.ensemble_kwargs,
                      ensemble_nbest=self.ensemble_nbest,
                      max_models_on_disc=self.max_models_on_disc,
                      seed=self.seed,
                      precision=self.precision,
                      memory_limit=self.memory_limit,
                      read_at_most=self.read_at_most,
                      random_state=self.random_state,
                      end_at=self.start_time
                      + self.time_left_for_ensembles,
                      iteration=self.iteration,
                      pynisher_context=self.pynisher_context,
                      logger_port=self.logger_port,
                  )
              )
  
              logger.info(
                  "{}/{} Started Ensemble builder job at {} for iteration {}.".format(
                      # Log the client to make sure we
                      # remain connected to the scheduler
                      self.futures[0],
                      dask_client,
                      time.strftime("%Y.%m.%d-%H.%M.%S"),
                      self.iteration,
                  ),
              )
              self.iteration += 1
          except Exception as e:
              exception_traceback = traceback.format_exc()
              error_message = repr(e)
              logger.critical(exception_traceback)
              logger.critical(error_message)
  
imports: from __future__ import annotations
  from typing import Any, Dict, Sequence, Type
  import logging.handlers
  import time
  import traceback
  import dask.distributed
  import numpy
  from sklearn.utils.validation import check_random_state
  from smac.callbacks import IncorporateRunResultCallback
  from smac.optimizer.smbo import SMBO
  from smac.runhistory.runhistory import RunInfo, RunValue
  from smac.tae.base import StatusType
  from autosklearn.automl_common.common.utils.backend import Backend
  from autosklearn.ensemble_building.builder import EnsembleBuilder
  from autosklearn.ensembles.abstract_ensemble import AbstractEnsemble
  from autosklearn.ensembles.ensemble_selection import EnsembleSelection
  from autosklearn.metrics import Scorer
  from autosklearn.util.logging_ import get_named_client_logger
label_desc: Use image node_id 3 for calling the EnsembleBuilderManager obj's underlying member method code with example usage: obj.build_ensemble(dask_client) without return types