code: def test_permutation_importance_no_weights_scoring_function():
      # Creating a scorer function that does not takes sample_weight
      def my_scorer(estimator, X, y):
          return 1
  
      # Creating some data and estimator for the permutation test
      x = np.array([[1, 2], [3, 4]])
      y = np.array([1, 2])
      w = np.array([1, 1])
      lr = LinearRegression()
      lr.fit(x, y)
  
      # test that permutation_importance does not return error when
      # sample_weight is None
      try:
          permutation_importance(
              lr, x, y, random_state=1, scoring=my_scorer, n_repeats=1
          )
      except TypeError:
          pytest.fail(
              "permutation_test raised an error when using a scorer "
              "function that does not accept sample_weight even though "
              "sample_weight was None"
          )
  
      # test that permutation_importance raise exception when sample_weight is
      # not None
      with pytest.raises(TypeError):
          permutation_importance(
              lr,
              x,
              y,
              random_state=1,
              scoring=my_scorer,
              n_repeats=1,
              sample_weight=w,
          )
  
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 11 for calling a global function with example usage: test_permutation_importance_no_weights_scoring_function() and returns: int