class_docstr: Base class for Bagging meta-estimator.
  
  Warning: This class should not be used directly. Use derived classes
  instead.
docstr: Build a Bagging ensemble of estimators from the training set (X, y).
  
  Parameters
  ----------
  X : {array-like, sparse matrix} of shape (n_samples, n_features)
      The training input samples. Sparse matrices are accepted only if
      they are supported by the base estimator.
  
  y : array-like of shape (n_samples,)
      The target values (class labels in classification, real numbers in
      regression).
  
  sample_weight : array-like of shape (n_samples,), default=None
      Sample weights. If None, then samples are equally weighted.
      Note that this is supported only if the base estimator supports
      sample weighting.
  
  Returns
  -------
  self : object
      Fitted estimator.
docstr_tok: ["Build","a","Bagging","ensemble","of","estimators","from","the","training","set","(","X",",","y",")",".","Parameters","--","--","--","--","--","X",":","{","array-like",",","sparse","matrix","}","of","shape","(","n_samples",",","n_features",")","The","training","input","samples",".","Sparse","matrices","are","accepted","only","if","they","are","supported","by","the","base","estimator",".","y",":","array-like","of","shape","(","n_samples",",",")","The","target","values","(","class","labels","in","classification",",","real","numbers","in","regression",")",".","sample_weight",":","array-like","of","shape","(","n_samples",",",")",",","default=None","Sample","weights",".","If","None",",","then","samples","are","equally","weighted",".","Note","that","this","is","supported","only","if","the","base","estimator","supports","sample","weighting",".","Returns","--","--","--","-","self",":","object","Fitted","estimator","."]
code: def fit(self, X, y, sample_weight=None):
      """Build a Bagging ensemble of estimators from the training set (X, y).
  
      Parameters
      ----------
      X : {array-like, sparse matrix} of shape (n_samples, n_features)
          The training input samples. Sparse matrices are accepted only if
          they are supported by the base estimator.
  
      y : array-like of shape (n_samples,)
          The target values (class labels in classification, real numbers in
          regression).
  
      sample_weight : array-like of shape (n_samples,), default=None
          Sample weights. If None, then samples are equally weighted.
          Note that this is supported only if the base estimator supports
          sample weighting.
  
      Returns
      -------
      self : object
          Fitted estimator.
      """
      _raise_for_unsupported_routing(
          self, "fit", sample_weight=sample_weight
      )
      # Convert data (X is required to be 2d and indexable)
      X, y = self._validate_data(
          X,
          y,
          accept_sparse=["csr", "csc"],
          dtype=None,
          force_all_finite=False,
          multi_output=True,
      )
      return self._fit(
          X, y, self.max_samples, sample_weight=sample_weight
      )
  
imports: import itertools
  import numbers
  from abc import ABCMeta, abstractmethod
  from functools import partial
  from numbers import Integral
  from warnings import warn
  import numpy
  from ..base import ClassifierMixin, RegressorMixin, _fit_context
  from ..metrics import accuracy_score, r2_score
  from ..tree import DecisionTreeClassifier, DecisionTreeRegressor
  from ..utils import check_random_state, column_or_1d, indices_to_mask
  from ..utils._param_validation import HasMethods, Interval, RealNotInt
  from ..utils._tags import _safe_tags
  from ..utils.metadata_routing import _raise_for_unsupported_routing, _RoutingNotSupportedMixin
  from ..utils.metaestimators import available_if
  from ..utils.multiclass import check_classification_targets
  from ..utils.parallel import Parallel, delayed
  from ..utils.random import sample_without_replacement
  from ..utils.validation import _check_sample_weight, check_is_fitted, has_fit_parameter
  from ._base import BaseEnsemble, _partition_estimators
label_desc: Use image node_id 2 for calling the BaseBagging obj's underlying member method code with example usage: obj.fit(X, y, sample_weight) and returns: self