code: def test_gen_moving_timeseries_forecast_with_regressors():
      """Test for `gen_moving_timeseries_forecast` with regressors"""
      data = generate_df_for_tests(freq="1H", periods=1000)
      df = data["df"]
      df["x"] = 40
  
      # A simple train-forecast function which always uses last available
      # value, then adds the regressor value -> forecasted value
      def train_forecast_func(
          df,
          value_col,
          time_col,
          forecast_horizon,
          new_external_regressor_df,
      ):
          # Simply get last observed value and offer as forecast
          value = df[value_col].values[-1]
          forecasted_values = np.repeat(
              a=value, repeats=forecast_horizon
          )
          fut_df = pd.DataFrame({value_col: forecasted_values})
          # Adds regerssor value
          fut_df[value_col] = (
              fut_df[value_col] + new_external_regressor_df["x"]
          )
          return {"fut_df": fut_df}
  
      compare_df = gen_moving_timeseries_forecast(
          df=df,
          time_col="ts",
          value_col="y",
          train_move_ahead=10,
          forecast_horizon=7,
          train_forecast_func=train_forecast_func,
          min_training_end_point=100,
          regressor_cols=["x"],
      )["compare_df"]
  
      assert (
          list(compare_df.head(5)["y_hat"].round(1).values)
          == [39.4] * 5
      )
  
imports: import numpy
  import pandas
  import pytest
  from greykite.common.gen_moving_timeseries_forecast import gen_moving_timeseries_forecast
  from greykite.common.testing_utils import generate_df_for_tests
label_desc: Use image node_id 2 for calling a global function with example usage: test_gen_moving_timeseries_forecast_with_regressors() and returns: dict