code: def test_evaluate_grid_hyperparameters_when_return_best_ForecasterAutoreg(
      lags_grid,
  ):
      """
      Test forecaster is refitted when return_best=True in
      _evaluate_grid_hyperparameters with ForecasterAutoreg.
      """
      forecaster = ForecasterAutoreg(
          regressor=Ridge(random_state=123), lags=2
      )
  
      steps = 3
      n_validation = 12
      y_train = y[:-n_validation]
      param_grid = [{"alpha": 0.01}, {"alpha": 0.1}, {"alpha": 1}]
  
      _evaluate_grid_hyperparameters(
          forecaster=forecaster,
          y=y,
          lags_grid=lags_grid,
          param_grid=param_grid,
          steps=steps,
          refit=False,
          metric="mean_squared_error",
          initial_train_size=len(y_train),
          fixed_train_size=False,
          return_best=True,
          verbose=False,
      )
  
      expected_lags = np.array([1, 2])
      expected_alpha = 0.01
  
      assert (expected_lags == forecaster.lags).all()
      assert expected_alpha == forecaster.regressor.alpha
  
imports: import re
  import pytest
  import numpy
  import pandas
  from sklearn.linear_model import Ridge
  from sklearn.metrics import mean_absolute_error
  from sklearn.metrics import mean_absolute_percentage_error
  from skforecast.ForecasterAutoreg import ForecasterAutoreg
  from skforecast.ForecasterAutoregCustom import ForecasterAutoregCustom
  from skforecast.model_selection.model_selection import _evaluate_grid_hyperparameters
  from tqdm import tqdm
  from functools import partialmethod
  from .fixtures_model_selection import y
label_desc: Use image node_id 11 for calling a global function with example usage: test_evaluate_grid_hyperparameters_when_return_best_ForecasterAutoreg(lags_grid) without return types