code: def test_create_sample_weights_exceptions_when_weights_has_nan():
      """
      Test sample_weights exception when weights contains NaNs.
      """
      forecaster = ForecasterAutoreg(
          lags=3,
          regressor=LinearRegression(),
          weight_func=custom_weights_nan,
      )
  
      err_msg = re.escape(
          "The resulting `sample_weight` cannot have NaN values."
      )
      with pytest.raises(ValueError, match=err_msg):
          forecaster.create_sample_weights(X_train=X_train)
  
file_path: skforecast/skforecast/ForecasterAutoreg/tests/test_create_sample_weights.py
imports: import re
  import pytest
  import numpy
  import pandas
  from skforecast.ForecasterAutoreg import ForecasterAutoreg
  from sklearn.linear_model import LinearRegression
label_desc: Use image node_id 6 for calling a global function with example usage: test_create_sample_weights_exceptions_when_weights_has_nan() without return types