code: def test_partial_dependence_helpers(est, method, target_feature):
      # Check that what is returned by _partial_dependence_brute or
      # _partial_dependence_recursion is equivalent to manually setting a target
      # feature to a given value, and computing the average prediction over all
      # samples.
      # This also checks that the brute and recursion methods give the same
      # output.
      # Note that even on the trainset, the brute and the recursion methods
      # aren't always strictly equivalent, in particular when the slow method
      # generates unrealistic samples that have low mass in the joint
      # distribution of the input features, and when some of the features are
      # dependent. Hence the high tolerance on the checks.
  
      X, y = make_regression(
          random_state=0, n_features=5, n_informative=5
      )
      # The 'init' estimator for GBDT (here the average prediction) isn't taken
      # into account with the recursion method, for technical reasons. We set
      # the mean to 0 to that this 'bug' doesn't have any effect.
      y = y - y.mean()
      est.fit(X, y)
  
      # target feature will be set to .5 and then to 123
      features = np.array([target_feature], dtype=np.int32)
      grid = np.array([[0.5], [123]])
  
      if method == "brute":
          pdp, predictions = _partial_dependence_brute(
              est, grid, features, X, response_method="auto"
          )
      else:
          pdp = _partial_dependence_recursion(est, grid, features)
  
      mean_predictions = []
      for val in (0.5, 123):
          X_ = X.copy()
          X_[:, target_feature] = val
          mean_predictions.append(est.predict(X_).mean())
  
      pdp = pdp[0]  # (shape is (1, 2) so make it (2,))
  
      # allow for greater margin for error with recursion method
      rtol = 1e-1 if method == "recursion" else 1e-3
      assert np.allclose(pdp, mean_predictions, rtol=rtol)
  
imports: import warnings
  import numpy
  import pytest
  import sklearn
  from sklearn.base import BaseEstimator, ClassifierMixin, clone, is_regressor
  from sklearn.cluster import KMeans
  from sklearn.compose import make_column_transformer
  from sklearn.datasets import load_iris, make_classification, make_regression
  from sklearn.dummy import DummyClassifier
  from sklearn.ensemble import GradientBoostingClassifier, GradientBoostingRegressor, HistGradientBoostingClassifier, HistGradientBoostingRegressor, RandomForestRegressor
  from sklearn.exceptions import NotFittedError
  from sklearn.inspection import partial_dependence
  from sklearn.inspection._partial_dependence import _grid_from_X, _partial_dependence_brute, _partial_dependence_recursion
  from sklearn.linear_model import LinearRegression, LogisticRegression, MultiTaskLasso
  from sklearn.metrics import r2_score
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import PolynomialFeatures, RobustScaler, StandardScaler, scale
  from sklearn.tree import DecisionTreeRegressor
  from sklearn.tree.tests.test_tree import assert_is_subtree
  from sklearn.utils import _IS_32BIT
  from sklearn.utils._testing import assert_allclose, assert_array_equal
  from sklearn.utils.validation import check_random_state
label_desc: Use image node_id 6 for calling a global function with example usage: test_partial_dependence_helpers(est, method, target_feature) without return types