code: def test_IgnoredArgumentWarning_initialize_weights_when_weight_func_is_provided_and_regressor_has_not_sample_weights():
      """
      Test IgnoredArgumentWarning is created when weight_func is provided but the regressor
      has no argument sample_weights in his fit method.
      """
  
      def weight_func():  # pragma: no cover
          pass
  
      warn_msg = re.escape(
          (
              f"Argument `weight_func` is ignored since regressor KNeighborsRegressor() "
              f"does not accept `sample_weight` in its `fit` method."
          )
      )
      with pytest.warns(IgnoredArgumentWarning, match=warn_msg):
          weight_func, source_code_weight_func, _ = initialize_weights(
              forecaster_name="ForecasterAutoreg",
              regressor=KNeighborsRegressor(),
              weight_func=weight_func,
              series_weights=None,
          )
  
      assert weight_func is None
      assert source_code_weight_func is None
  
file_path: skforecast/skforecast/utils/tests/test_initialize_weights.py
imports: import re
  import pytest
  import numpy
  import pandas
  import inspect
  from skforecast.exceptions import IgnoredArgumentWarning
  from skforecast.utils.utils import initialize_weights
  from sklearn.linear_model import LinearRegression
  from sklearn.ensemble import RandomForestRegressor
  from sklearn.neighbors import KNeighborsRegressor
label_desc: Use image node_id 4 for calling a global function with example usage: test_IgnoredArgumentWarning_initialize_weights_when_weight_func_is_provided_and_regressor_has_not_sample_weights() without return types