code: def test_train_and_predict(params, hourly_data_with_reg):
      """Tests train and prediction functionality."""
      params["model_configs"][0].estimator_params["regressor_cols"] = [
          "regressor"
      ]
      model = MultistageForecastEstimator(**params)
      # fit
      model.fit(hourly_data_with_reg)
      # predict training period
      pred = model.predict(hourly_data_with_reg)
      assert pred.shape[0] == hourly_data_with_reg.shape[0]
      # predict future period
      pred = model.predict(
          pd.DataFrame(
              {
                  cst.TIME_COL: pd.date_range(
                      start=hourly_data_with_reg[cst.TIME_COL].max(),
                      freq="H",
                      periods=13,
                  )[1:],
                  cst.VALUE_COL: np.nan,
                  "regressor": 1,
              }
          )
      )
      assert pred.shape[0] == 12
      assert pred[cst.PREDICTED_COL].dropna().shape[0] == 12
      # checks values-
      assert (
          model.fit_df[f"{cst.VALUE_COL}__0__D"].dropna().shape[0] >= 30
      )  # daily training size
      assert (
          model.fit_df[f"{cst.VALUE_COL}__1__H"].dropna().shape[0]
          >= 24 * 7
      )  # hourly training size
      assert (
          model.fit_df[f"{cst.PREDICTED_COL}__0__D"].dropna().shape[0]
          >= 30
      )  # daily fit size
      assert (
          model.fit_df[f"{cst.PREDICTED_COL}__1__H"].dropna().shape[0]
          >= 30
      )  # daily fit size
  
      # makes sure the AR orders are correct
      assert "y_lag1" in model.models[0].model_dict["x_mat"].columns
      assert "y_lag12" in model.models[1].model_dict["x_mat"].columns
      # components plot
      plots = model.plot_components()
      assert len(plots) == 2
      # summary
      summaries = model.summary()
      assert len(summaries) == 2
  
imports: import datetime
  import numpy
  import pandas
  import pytest
  from testfixtures import LogCapture
  import greykite.common.constants
  from greykite.common.testing_utils import generate_df_for_tests
  from greykite.sklearn.estimator.lag_based_estimator import LagBasedEstimator
  from greykite.sklearn.estimator.multistage_forecast_estimator import MultistageForecastEstimator
  from greykite.sklearn.estimator.multistage_forecast_estimator import MultistageForecastModelConfig
  from greykite.sklearn.estimator.simple_silverkite_estimator import SimpleSilverkiteEstimator
  from greykite.sklearn.uncertainty.uncertainty_methods import UncertaintyMethodEnum
label_desc: Use image node_id 18 for calling a global function with example usage: test_train_and_predict(params, hourly_data_with_reg) without return types