code: def test_bootstrap_samples():
      # Test that bootstrapping samples generate non-perfect base estimators.
      rng = check_random_state(0)
      X_train, X_test, y_train, y_test = train_test_split(
          diabetes.data, diabetes.target, random_state=rng
      )
  
      estimator = DecisionTreeRegressor().fit(X_train, y_train)
  
      # without bootstrap, all trees are perfect on the training set
      ensemble = BaggingRegressor(
          estimator=DecisionTreeRegressor(),
          max_samples=1.0,
          bootstrap=False,
          random_state=rng,
      ).fit(X_train, y_train)
  
      assert estimator.score(X_train, y_train) == ensemble.score(
          X_train, y_train
      )
  
      # with bootstrap, trees are no longer perfect on the training set
      ensemble = BaggingRegressor(
          estimator=DecisionTreeRegressor(),
          max_samples=1.0,
          bootstrap=True,
          random_state=rng,
      ).fit(X_train, y_train)
  
      assert estimator.score(X_train, y_train) > ensemble.score(
          X_train, y_train
      )
  
      # check that each sampling correspond to a complete bootstrap resample.
      # the size of each bootstrap should be the same as the input data but
      # the data should be different (checked using the hash of the data).
      ensemble = BaggingRegressor(
          estimator=DummySizeEstimator(), bootstrap=True
      ).fit(X_train, y_train)
      training_hash = []
      for estimator in ensemble.estimators_:
          assert estimator.training_size_ == X_train.shape[0]
          training_hash.append(estimator.training_hash_)
      assert len(set(training_hash)) == len(training_hash)
  
imports: from itertools import cycle, product
  import joblib
  import numpy
  import pytest
  from sklearn.base import BaseEstimator
  from sklearn.datasets import load_diabetes, load_iris, make_hastie_10_2
  from sklearn.dummy import DummyClassifier, DummyRegressor
  from sklearn.ensemble import BaggingClassifier, BaggingRegressor, HistGradientBoostingClassifier, HistGradientBoostingRegressor
  from sklearn.feature_selection import SelectKBest
  from sklearn.linear_model import LogisticRegression, Perceptron
  from sklearn.model_selection import GridSearchCV, ParameterGrid, train_test_split
  from sklearn.neighbors import KNeighborsClassifier, KNeighborsRegressor
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import FunctionTransformer, scale
  from sklearn.random_projection import SparseRandomProjection
  from sklearn.svm import SVC, SVR
  from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
  from sklearn.utils import check_random_state
  from sklearn.utils._testing import assert_array_almost_equal, assert_array_equal
  from sklearn.utils.fixes import CSC_CONTAINERS, CSR_CONTAINERS
label_desc: Use image node_id 5 for calling a global function with example usage: test_bootstrap_samples() without return types