code: def test_permutation_importance_correlated_feature_regression(
      n_jobs, max_samples
  ):
      # Make sure that feature highly correlated to the target have a higher
      # importance
      rng = np.random.RandomState(42)
      n_repeats = 5
  
      X, y = load_diabetes(return_X_y=True)
      y_with_little_noise = (
          y + rng.normal(scale=0.001, size=y.shape[0])
      ).reshape(-1, 1)
  
      X = np.hstack([X, y_with_little_noise])
  
      clf = RandomForestRegressor(n_estimators=10, random_state=42)
      clf.fit(X, y)
  
      result = permutation_importance(
          clf,
          X,
          y,
          n_repeats=n_repeats,
          random_state=rng,
          n_jobs=n_jobs,
          max_samples=max_samples,
      )
  
      assert result.importances.shape == (X.shape[1], n_repeats)
  
      # the correlated feature with y was added as the last column and should
      # have the highest importance
      assert np.all(
          result.importances_mean[-1] > result.importances_mean[:-1]
      )
  
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose
  from sklearn.compose import ColumnTransformer
  from sklearn.datasets import load_diabetes, load_iris, make_classification, make_regression
  from sklearn.dummy import DummyClassifier
  from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
  from sklearn.impute import SimpleImputer
  from sklearn.inspection import permutation_importance
  from sklearn.linear_model import LinearRegression, LogisticRegression
  from sklearn.metrics import get_scorer, mean_squared_error, r2_score
  from sklearn.model_selection import train_test_split
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import KBinsDiscretizer, OneHotEncoder, StandardScaler, scale
  from sklearn.utils import parallel_backend
  from sklearn.utils._testing import _convert_container
label_desc: Use image node_id 1 for calling a global function with example usage: test_permutation_importance_correlated_feature_regression(n_jobs, max_samples) without return types