docstr: Fit an ensemble to models trained during an optimization process.
  
  All parameters are ``None`` by default. If no other value is given,
  the default values which were set in a call to ``fit()`` are used.
  
  Parameters
  ----------
  y : array-like
      Target values.
  
  task : int
      A constant from the module ``autosklearn.constants``. Determines
      the task type (binary classification, multiclass classification,
      multilabel classification or regression).
  
  precision : int
      Numeric precision used when loading ensemble data. Can be either
      ``16``, ``32`` or ``64``.
  
  dataset_name : str
      Name of the current data set.
  
  ensemble_size : int, optional
      Number of models added to the ensemble built by *Ensemble
      selection from libraries of models*. Models are drawn with
      replacement. If set to ``0`` no ensemble is fit.
  
      Deprecated - will be removed in Auto-sklearn 0.16. Please pass
      this argument via ``ensemble_kwargs={"ensemble_size": int}``
      if you want to change the ensemble size for ensemble selection.
  
  ensemble_kwargs : Dict, optional
      Keyword arguments that are passed to the ensemble class upon
      initialization.
  
  ensemble_nbest : int
      Only consider the ``ensemble_nbest`` models when building an
      ensemble. This is inspired by a concept called library pruning
      introduced in `Getting Most out of Ensemble Selection`. This
      is independent of the ``ensemble_class`` argument and this
      pruning step is done prior to constructing an ensemble.
  
  ensemble_class : Type[AbstractEnsemble] | "default", optional (default="default")
      Class implementing the post-hoc ensemble algorithm. Set to
      ``None`` to disable ensemble building or use class:`SingleBest`
      to obtain only use the single best model instead of an
      ensemble.
  
      If set to "default" it will use :class:`EnsembleSelection` for
      single-objective problems and :class:`MultiObjectiveDummyEnsemble`
      for multi-objective problems.
  
  metric: Scorer | Sequence[Scorer] | None = None
      A metric or list of metrics to score the ensemble with
  
  Returns
  -------
  self
docstr_tok: ["Fit","an","ensemble","to","models","trained","during","an","optimization","process",".","All","parameters","are","``","None","``","by","default",".","If","no","other","value","is","given",",","the","default","values","which","were","set","in","a","call","to","``","fit","(",")","``","are","used",".","Parameters","--","--","--","--","--","y",":","array-like","Target","values",".","task",":","int","A","constant","from","the","module","``","autosklearn.constants","``",".","Determines","the","task","type","(","binary","classification",",","multiclass","classification",",","multilabel","classification","or","regression",")",".","precision",":","int","Numeric","precision","used","when","loading","ensemble","data",".","Can","be","either","``","16","``",",","``","32","``","or","``","64","``",".","dataset_name",":","str","Name","of","the","current","data","set",".","ensemble_size",":","int",",","optional","Number","of","models","added","to","the","ensemble","built","by","*","Ensemble","selection","from","libraries","of","models","*",".","Models","are","drawn","with","replacement",".","If","set","to","``","0","``","no","ensemble","is","fit",".","Deprecated","-","will","be","removed","in","Auto-sklearn","0.16",".","Please","pass","this","argument","via","``","ensemble_kwargs=","{","``","ensemble_size","''",":","int","}","``","if","you","want","to","change","the","ensemble","size","for","ensemble","selection",".","ensemble_kwargs",":","Dict",",","optional","Keyword","arguments","that","are","passed","to","the","ensemble","class","upon","initialization",".","ensemble_nbest",":","int","Only","consider","the","``","ensemble_nbest","``","models","when","building","an","ensemble",".","This","is","inspired","by","a","concept","called","library","pruning","introduced","in","`","Getting","Most","out","of","Ensemble","Selection","`",".","This","is","independent","of","the","``","ensemble_class","``","argument","and","this","pruning","step","is","done","prior","to","constructing","an","ensemble",".","ensemble_class",":","Type","[","AbstractEnsemble","]","|","``","default","''",",","optional","(","default=","''","default","''",")","Class","implementing","the","post-hoc","ensemble","algorithm",".","Set","to","``","None","``","to","disable","ensemble","building","or","use","class",":","`","SingleBest","`","to","obtain","only","use","the","single","best","model","instead","of","an","ensemble",".","If","set","to","``","default","''","it","will","use",":","class",":","`","EnsembleSelection","`","for","single-objective","problems","and",":","class",":","`","MultiObjectiveDummyEnsemble","`","for","multi-objective","problems",".","metric",":","Scorer","|","Sequence","[","Scorer","]","|","None","=","None","A","metric","or","list","of","metrics","to","score","the","ensemble","with","Returns","--","--","--","-","self"]
code: def fit_ensemble(
      self,
      y,
      task: int = None,
      precision: Literal[16, 21, 64] = 32,
      dataset_name: Optional[str] = None,
      ensemble_size: int | None = None,
      ensemble_kwargs: Optional[Dict[str, Any]] = None,
      ensemble_nbest: Optional[int] = None,
      ensemble_class: Type[AbstractEnsemble]
      | Literal["default"]
      | None = "default",
      metric: Scorer | Sequence[Scorer] | None = None,
  ):
      """Fit an ensemble to models trained during an optimization process.
  
      All parameters are ``None`` by default. If no other value is given,
      the default values which were set in a call to ``fit()`` are used.
  
      Parameters
      ----------
      y : array-like
          Target values.
  
      task : int
          A constant from the module ``autosklearn.constants``. Determines
          the task type (binary classification, multiclass classification,
          multilabel classification or regression).
  
      precision : int
          Numeric precision used when loading ensemble data. Can be either
          ``16``, ``32`` or ``64``.
  
      dataset_name : str
          Name of the current data set.
  
      ensemble_size : int, optional
          Number of models added to the ensemble built by *Ensemble
          selection from libraries of models*. Models are drawn with
          replacement. If set to ``0`` no ensemble is fit.
  
          Deprecated - will be removed in Auto-sklearn 0.16. Please pass
          this argument via ``ensemble_kwargs={"ensemble_size": int}``
          if you want to change the ensemble size for ensemble selection.
  
      ensemble_kwargs : Dict, optional
          Keyword arguments that are passed to the ensemble class upon
          initialization.
  
      ensemble_nbest : int
          Only consider the ``ensemble_nbest`` models when building an
          ensemble. This is inspired by a concept called library pruning
          introduced in `Getting Most out of Ensemble Selection`. This
          is independent of the ``ensemble_class`` argument and this
          pruning step is done prior to constructing an ensemble.
  
      ensemble_class : Type[AbstractEnsemble] | "default", optional (default="default")
          Class implementing the post-hoc ensemble algorithm. Set to
          ``None`` to disable ensemble building or use class:`SingleBest`
          to obtain only use the single best model instead of an
          ensemble.
  
          If set to "default" it will use :class:`EnsembleSelection` for
          single-objective problems and :class:`MultiObjectiveDummyEnsemble`
          for multi-objective problems.
  
      metric: Scorer | Sequence[Scorer] | None = None
          A metric or list of metrics to score the ensemble with
  
      Returns
      -------
      self
      """  # noqa: E501
  
      if ensemble_class == "default":
          # Things are actually a little more nuanced here:
          # * If they passed `metric=None` at init, we would infer this in automl
          #   during `fit` and store it in the automl instance.
          # * If they passed a `metric` in init and left it `None` here, this would
          #   also be in the automl instance
          # => We can use self.automl_ as ground truth for metric if no metrics passed
          #   and we have one created
          if (
              metric is None
              and self.automl_ is not None
              and self.automl_._metrics
          ):
              metric = self.automl_._metrics
  
          ensemble_class = self._resolve_ensemble_class(metric)
  
      self.ensemble_class = ensemble_class
  
      # User specified `ensemble_size` explicitly, warn them about deprecation
      if ensemble_size is not None:
          # Keep consistent behaviour
          message = (
              "`ensemble_size` has been deprecated, please use `ensemble_kwargs = "
              "{'ensemble_size': %d}`. Inserting `ensemble_size` into "
              "`ensemble_kwargs` for now. `ensemble_size` will be removed in "
              "auto-sklearn 0.16."
          ) % ensemble_size
          if ensemble_class == EnsembleSelection:
              if ensemble_kwargs is None:
                  ensemble_kwargs = {"ensemble_size": ensemble_size}
                  warnings.warn(
                      message, DeprecationWarning, stacklevel=2
                  )
              elif "ensemble_size" not in ensemble_kwargs:
                  ensemble_kwargs["ensemble_size"] = ensemble_size
                  warnings.warn(
                      message, DeprecationWarning, stacklevel=2
                  )
              else:
                  warnings.warn(
                      "Deprecated argument `ensemble_size` is both provided "
                      "as an argument to the constructor and passed inside "
                      "`ensemble_kwargs`. Will ignore the argument and use "
                      "the value given in `ensemble_kwargs` (%d). `ensemble_size` "
                      "will be removed in auto-sklearn 0.16."
                      % ensemble_kwargs["ensemble_size"],
                      DeprecationWarning,
                      stacklevel=2,
                  )
          else:
              warnings.warn(
                  "`ensemble_size` has been deprecated, please use "
                  "`ensemble_kwargs = {'ensemble_size': %d} if this "
                  "was intended. Ignoring `ensemble_size` because "
                  "`ensemble_class` != EnsembleSelection. "
                  "`ensemble_size` will be removed in auto-sklearn 0.16."
                  % ensemble_size,
                  DeprecationWarning,
                  stacklevel=2,
              )
  
      if self.automl_ is None:
          # Build a dummy automl object to call fit_ensemble
          # The ensemble size is honored in the .automl_.fit_ensemble
          # call
          self.automl_ = self.build_automl()
      self.automl_.fit_ensemble(
          y=y,
          task=task,
          precision=precision,
          dataset_name=dataset_name,
          ensemble_nbest=ensemble_nbest,
          ensemble_class=ensemble_class,
          ensemble_kwargs=ensemble_kwargs,
          metrics=metric,
      )
      return self
  
imports: from __future__ import annotations
  from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, Union
  import warnings
  import dask.distributed
  import joblib
  import numpy
  import pandas
  from ConfigSpace.configuration_space import Configuration, ConfigurationSpace
  from scipy.sparse import spmatrix
  from sklearn.base import BaseEstimator, ClassifierMixin, RegressorMixin
  from sklearn.ensemble import VotingClassifier, VotingRegressor
  from sklearn.utils.multiclass import type_of_target
  from smac.runhistory.runhistory import RunInfo, RunValue
  from typing_extensions import Literal
  from autosklearn.automl import AutoML, AutoMLClassifier, AutoMLRegressor
  from autosklearn.data.validation import SUPPORTED_FEAT_TYPES, SUPPORTED_TARGET_TYPES, convert_if_sparse
  from autosklearn.ensembles.abstract_ensemble import AbstractEnsemble
  from autosklearn.ensembles.ensemble_selection import EnsembleSelection
  from autosklearn.ensembles.multiobjective_dummy_ensemble import MultiObjectiveDummyEnsemble
  from autosklearn.metrics import Scorer
  from autosklearn.pipeline.base import BasePipeline
  from autosklearn.util.smac_wrap import SMACCallback
label_desc: Use image node_id 6 for calling the AutoSklearnEstimator obj's underlying member method code with example usage: obj.fit_ensemble(y, task, precision, dataset_name, ensemble_size, ensemble_kwargs, ensemble_nbest, ensemble_class, metric) and returns: self