code: def test_run_template_6():
      """Runs custom template with monthly data, auto-regression and lagged regressors"""
      data = generate_df_with_reg_for_tests(
          freq="MS",
          periods=48,
          remove_extra_cols=True,
          mask_test_actuals=True,
      )
      reg_cols_all = ["regressor1", "regressor2", "regressor_categ"]
      reg_cols = ["regressor1"]
      keep_cols = [TIME_COL, VALUE_COL] + reg_cols_all
      df = data["df"][keep_cols]
      test_df = data["test_df"]
      forecast_horizon = test_df.shape[0]
  
      model_components = ModelComponentsParam(
          custom=dict(
              fit_algorithm_dict=dict(fit_algorithm="linear"),
              extra_pred_cols=reg_cols,
          ),
          autoregression=dict(
              autoreg_dict=dict(lag_dict=dict(orders=[1]))
          ),
          lagged_regressors={
              "lagged_regressor_dict": [
                  {"regressor_categ": {"lag_dict": {"orders": [1, 5]}}},
                  {"regressor_categ": {"lag_dict": {"orders": [5]}}},
              ]
          },
          uncertainty=dict(uncertainty_dict=None),
      )
      config = ForecastConfig(
          model_template=ModelTemplateEnum.SK.name,
          forecast_horizon=forecast_horizon,
          coverage=0.9,
          model_components_param=model_components,
      )
  
      with warnings.catch_warnings():
          warnings.simplefilter("ignore")
          result = Forecaster().run_forecast_config(
              df=df,
              config=config,
          )
          rmse = (
              EvaluationMetricEnum.RootMeanSquaredError.get_metric_name()
          )
          assert result.backtest.test_evaluation[rmse] == pytest.approx(
              5.44, rel=1e-1
          )
          check_forecast_pipeline_result(
              result,
              coverage=0.9,
              strategy=None,
              score_func=EvaluationMetricEnum.MeanAbsolutePercentError.name,
              greater_is_better=False,
          )
          # Checks lagged regressor columns
          # Both models include lagged regressors, since a CV was run,
          # the best model picked turns out to be the one with
          # `"regressor_categ": {"lag_dict": {"orders": [1, 5]}`.
          # But either model must contain `lag5`, we verify its existence.
          actual_pred_cols = set(
              result.model[-1].model_dict["pred_cols"]
          )
          actual_x_mat_cols = set(
              result.model[-1].model_dict["x_mat"].columns
          )
          expected_pred_cols = {
              "regressor1",
              "y_lag1",
              "regressor_categ_lag5",
          }
          expected_x_mat_cols = {
              "regressor1",
              "y_lag1",
              "regressor_categ_lag5[T.c2]",
              "regressor_categ_lag5[T.c2]",
          }
          assert expected_pred_cols.issubset(actual_pred_cols)
          assert expected_x_mat_cols.issubset(actual_x_mat_cols)
  
          trained_estimator = result.model[-1]
          forecast = trained_estimator.forecast
          forecast_x_mat = trained_estimator.forecast_x_mat
          fit_x_mat = trained_estimator.model_dict["x_mat"]
          assert len(forecast) == len(df)
          assert len(forecast_x_mat) == len(df)
          assert len(fit_x_mat) == len(df) - forecast_horizon
  
          # Does a new prediction and checks if the ``forecast`` and
          # ``forecast_x_mat`` are updated
          pred_df = trained_estimator.predict(test_df[:3])
          forecast_x_mat = trained_estimator.forecast_x_mat
          forecast = trained_estimator.forecast
          assert len(pred_df) == 3
          assert len(forecast) == 3
          assert len(forecast_x_mat) == 3
  
imports: import dataclasses
  import datetime
  import warnings
  import numpy
  import pandas
  import pytest
  from greykite.algo.forecast.silverkite.forecast_silverkite import SilverkiteForecast
  from greykite.algo.forecast.silverkite.forecast_simple_silverkite_helper import generate_holiday_events
  from greykite.algo.forecast.silverkite.forecast_simple_silverkite_helper import get_event_pred_cols
  from greykite.common.constants import ADJUSTMENT_DELTA_COL
  from greykite.common.constants import END_TIME_COL
  from greykite.common.constants import METRIC_COL
  from greykite.common.constants import PREDICTION_BAND_COVERAGE
  from greykite.common.constants import START_TIME_COL
  from greykite.common.constants import TIME_COL
  from greykite.common.constants import VALUE_COL
  from greykite.common.evaluation import EvaluationMetricEnum
  from greykite.common.python_utils import assert_equal
  from greykite.common.testing_utils import generate_df_for_tests
  from greykite.common.testing_utils import generate_df_with_reg_for_tests
  from greykite.framework.constants import COMPUTATION_N_JOBS
  from greykite.framework.constants import CV_REPORT_METRICS_ALL
  from greykite.framework.templates.autogen.forecast_config import ComputationParam
  from greykite.framework.templates.autogen.forecast_config import EvaluationMetricParam
  from greykite.framework.templates.autogen.forecast_config import EvaluationPeriodParam
  from greykite.framework.templates.autogen.forecast_config import ForecastConfig
  from greykite.framework.templates.autogen.forecast_config import MetadataParam
  from greykite.framework.templates.autogen.forecast_config import ModelComponentsParam
  from greykite.framework.templates.forecaster import Forecaster
  from greykite.framework.templates.model_templates import ModelTemplateEnum
  from greykite.framework.templates.silverkite_template import SilverkiteTemplate
  from greykite.framework.templates.silverkite_template import apply_default_model_components
  from greykite.framework.templates.silverkite_template import get_extra_pred_cols
  from greykite.framework.utils.framework_testing_utils import assert_basic_pipeline_equal
  from greykite.framework.utils.framework_testing_utils import check_forecast_pipeline_result
  from greykite.sklearn.estimator.silverkite_estimator import SilverkiteEstimator
label_desc: Use image node_id 17 for calling a global function with example usage: test_run_template_6() without return types