class_docstr: Base class for stacking method.
docstr: Fit the estimators.
  
  Parameters
  ----------
  X : {array-like, sparse matrix} of shape (n_samples, n_features)
      Training vectors, where `n_samples` is the number of samples and
      `n_features` is the number of features.
  
  y : array-like of shape (n_samples,)
      Target values.
  
  sample_weight : array-like of shape (n_samples,) or default=None
      Sample weights. If None, then samples are equally weighted.
      Note that this is supported only if all underlying estimators
      support sample weights.
  
      .. versionchanged:: 0.23
         when not None, `sample_weight` is passed to all underlying
         estimators
  
  Returns
  -------
  self : object
docstr_tok: ["Fit","the","estimators",".","Parameters","--","--","--","--","--","X",":","{","array-like",",","sparse","matrix","}","of","shape","(","n_samples",",","n_features",")","Training","vectors",",","where","`","n_samples","`","is","the","number","of","samples","and","`","n_features","`","is","the","number","of","features",".","y",":","array-like","of","shape","(","n_samples",",",")","Target","values",".","sample_weight",":","array-like","of","shape","(","n_samples",",",")","or","default=None","Sample","weights",".","If","None",",","then","samples","are","equally","weighted",".","Note","that","this","is","supported","only","if","all","underlying","estimators","support","sample","weights",".","..","versionchanged",":",":","0.23","when","not","None",",","`","sample_weight","`","is","passed","to","all","underlying","estimators","Returns","--","--","--","-","self",":","object"]
code: def fit(self, X, y, sample_weight=None):
      """Fit the estimators.
  
      Parameters
      ----------
      X : {array-like, sparse matrix} of shape (n_samples, n_features)
          Training vectors, where `n_samples` is the number of samples and
          `n_features` is the number of features.
  
      y : array-like of shape (n_samples,)
          Target values.
  
      sample_weight : array-like of shape (n_samples,) or default=None
          Sample weights. If None, then samples are equally weighted.
          Note that this is supported only if all underlying estimators
          support sample weights.
  
          .. versionchanged:: 0.23
             when not None, `sample_weight` is passed to all underlying
             estimators
  
      Returns
      -------
      self : object
      """
      # all_estimators contains all estimators, the one to be fitted and the
      # 'drop' string.
      names, all_estimators = self._validate_estimators()
      self._validate_final_estimator()
  
      stack_method = [self.stack_method] * len(all_estimators)
  
      if self.cv == "prefit":
          self.estimators_ = []
          for estimator in all_estimators:
              if estimator != "drop":
                  check_is_fitted(estimator)
                  self.estimators_.append(estimator)
      else:
          # Fit the base estimators on the whole training data. Those
          # base estimators will be used in transform, predict, and
          # predict_proba. They are exposed publicly.
          self.estimators_ = Parallel(n_jobs=self.n_jobs)(
              delayed(_fit_single_estimator)(
                  clone(est), X, y, sample_weight
              )
              for est in all_estimators
              if est != "drop"
          )
  
      self.named_estimators_ = Bunch()
      est_fitted_idx = 0
      for name_est, org_est in zip(names, all_estimators):
          if org_est != "drop":
              current_estimator = self.estimators_[est_fitted_idx]
              self.named_estimators_[name_est] = current_estimator
              est_fitted_idx += 1
              if hasattr(current_estimator, "feature_names_in_"):
                  self.feature_names_in_ = (
                      current_estimator.feature_names_in_
                  )
          else:
              self.named_estimators_[name_est] = "drop"
  
      self.stack_method_ = [
          self._method_name(name, est, meth)
          for name, est, meth in zip(
              names, all_estimators, stack_method
          )
      ]
  
      if self.cv == "prefit":
          # Generate predictions from prefit models
          predictions = [
              getattr(estimator, predict_method)(X)
              for estimator, predict_method in zip(
                  all_estimators, self.stack_method_
              )
              if estimator != "drop"
          ]
      else:
          # To train the meta-classifier using the most data as possible, we use
          # a cross-validation to obtain the output of the stacked estimators.
          # To ensure that the data provided to each estimator are the same,
          # we need to set the random state of the cv if there is one and we
          # need to take a copy.
          cv = check_cv(self.cv, y=y, classifier=is_classifier(self))
          if hasattr(cv, "random_state") and cv.random_state is None:
              cv.random_state = np.random.RandomState()
  
          fit_params = (
              {"sample_weight": sample_weight}
              if sample_weight is not None
              else None
          )
          predictions = Parallel(n_jobs=self.n_jobs)(
              delayed(cross_val_predict)(
                  clone(est),
                  X,
                  y,
                  cv=deepcopy(cv),
                  method=meth,
                  n_jobs=self.n_jobs,
                  fit_params=fit_params,
                  verbose=self.verbose,
              )
              for est, meth in zip(all_estimators, self.stack_method_)
              if est != "drop"
          )
  
      # Only not None or not 'drop' estimators will be used in transform.
      # Remove the None from the method as well.
      self.stack_method_ = [
          meth
          for (meth, est) in zip(self.stack_method_, all_estimators)
          if est != "drop"
      ]
  
      X_meta = self._concatenate_predictions(X, predictions)
      _fit_single_estimator(
          self.final_estimator_, X_meta, y, sample_weight=sample_weight
      )
  
      return self
  
imports: from abc import ABCMeta, abstractmethod
  from copy import deepcopy
  from numbers import Integral
  import numpy
  import scipy.sparse
  from ..base import ClassifierMixin, RegressorMixin, TransformerMixin, _fit_context, clone, is_classifier, is_regressor
  from ..exceptions import NotFittedError
  from ..linear_model import LogisticRegression, RidgeCV
  from ..model_selection import check_cv, cross_val_predict
  from ..preprocessing import LabelEncoder
  from ..utils import Bunch
  from ..utils._estimator_html_repr import _VisualBlock
  from ..utils._param_validation import HasMethods, StrOptions
  from ..utils.metaestimators import available_if
  from ..utils.multiclass import check_classification_targets, type_of_target
  from ..utils.parallel import Parallel, delayed
  from ..utils.validation import _check_feature_names_in, _check_response_method, check_is_fitted, column_or_1d
  from ._base import _BaseHeterogeneousEnsemble, _fit_single_estimator
label_desc: Use image node_id 5 for calling the _BaseStacking obj's underlying member method code with example usage: obj.fit(X, y, sample_weight) and returns: self