code: def test_pipeline_end2end_predict():
      """Tests for `forecast_pipeline` predictions and design matrix validity."""
      warnings.simplefilter("ignore")
  
      # Generates data
      forecast_horizon = 20
      data = generate_df_for_tests(freq="H", periods=24 * 10)
      train_df = data["train_df"][[TIME_COL, VALUE_COL]]
      test_df = data["test_df"][[TIME_COL, VALUE_COL]][
          :forecast_horizon
      ]
  
      # Sets hyperparameter grid
      hyperparameter_grid = {
          "estimator__weekly_seasonality": [False],
          "estimator__daily_seasonality": [False],
          "estimator__holiday_lookup_countries": [None],
          "estimator__extra_pred_cols": [["ct1", "ct2"]],
      }
  
      # Fits and predicts using pipeline
      result = forecast_pipeline(
          df=train_df,
          score_func=EvaluationMetricEnum.MeanSquaredError.name,
          estimator=SimpleSilverkiteEstimator(),
          forecast_horizon=forecast_horizon,
          coverage=0.95,
          test_horizon=None,
          hyperparameter_grid=hyperparameter_grid,
          cv_horizon=24,
          cv_min_train_periods=24 * 30,
          cv_report_metrics=None,
          cv_max_splits=1,
          hyperparameter_budget=1,
          relative_error_tolerance=0.02,
          n_jobs=1,
      )
  
      # Tests to see if parameters are set from hyperparameter_grid
      backtest_params = result.grid_search.best_estimator_.get_params()
      forecast_params = result.model.get_params()
      for params in [backtest_params, forecast_params]:
          assert params["estimator__weekly_seasonality"] is False
          assert params["estimator__daily_seasonality"] is False
          assert params["estimator__holiday_lookup_countries"] is None
          assert params["estimator__extra_pred_cols"] == ["ct1", "ct2"]
  
      # Gets the final estimator
      trained_estimator = result.model[-1]
  
      forecast_x_mat = trained_estimator.forecast_x_mat
      # Regression coefficients
      model_coef = trained_estimator.coef_
      # Regression coefficients directly from ML models
      ml_model_coef = trained_estimator.model_dict["ml_model"].coef_
      # Extracts original forecasts from the pipeline
      pipeline_original_forecast = trained_estimator.forecast[
          -forecast_horizon:
      ].reset_index(drop=True)
  
      # The returned coefficients from ML model must be the same as final coefficients
      assert (ml_model_coef == model_coef[0].values).all()
  
      # Checks to see if multiplying the variables with regression coefficients is possible
      # and works as expected
      # Multiplies each row of the design matrix by regression coefficients (element-wise)
      # and returns a dataframe of same shape as ``forecast_x_mat``
      forecast_x_mat_weighted = forecast_x_mat * ml_model_coef
  
      assert list(forecast_x_mat) == ["Intercept", "ct1", "ct2"]
      assert list(model_coef.index) == ["Intercept", "ct1", "ct2"]
      # We expect the forecasted data and design matrix having a size equal to
      # "trained data size" + "forecast horizon"
      assert len(forecast_x_mat) == len(train_df) + forecast_horizon
      assert forecast_x_mat_weighted.shape == forecast_x_mat.shape
      assert (
          len(trained_estimator.forecast)
          == len(train_df) + forecast_horizon
      )
  
      # Checks to see if the manually calculated forecast is consistent
      # with returned forecast in terms of correlation
      # Note that they will not be the same scale due to (affine) transformations
      calculated_forecast = forecast_x_mat_weighted.sum(axis=1)
      forecast_corr = calculated_forecast.corr(
          trained_estimator.forecast["y"]
      )
      assert round(forecast_corr, 3) == 1.0
  
      pred_df = trained_estimator.predict(test_df[:forecast_horizon])
      pred_df.rename(columns={"forecast": "y"}, inplace=True)
      cols = [
          "ts",
          "y",
          "forecast_lower",
          "forecast_upper",
          QUANTILE_SUMMARY_COL,
          "err_std",
      ]
  
      # We expect the predictions to be the same as original predictions
      # since we are passing the same test data
      assert_equal(pred_df[cols], pipeline_original_forecast[cols])
  
      # Tries a new forecast horizon (10)
      new_pred_df = trained_estimator.predict(test_df[:10])
      new_pred_df.rename(columns={"forecast": "y"}, inplace=True)
      cols = [
          "ts",
          "y",
          "forecast_lower",
          "forecast_upper",
          QUANTILE_SUMMARY_COL,
          "err_std",
      ]
  
      # Checks to see if forecat and design matrix are updated in the estimator
      assert len(new_pred_df) == 10
      assert len(trained_estimator.forecast) == 10
      assert len(trained_estimator.forecast_x_mat) == 10
      # We expect the predictions to be the same as the first 10 rows of original predictions,
      # since we are passing the first 10 rows of the same test data
      assert_equal(
          new_pred_df[cols], pipeline_original_forecast[:10][cols]
      )
  
imports: import datetime
  import math
  import sys
  import warnings
  import numpy
  import pandas
  import pytest
  from scipy.stats import randint
  from sklearn.metrics import explained_variance_score
  from sklearn.metrics import mean_absolute_error
  from sklearn.metrics import mean_squared_error
  from sklearn.pipeline import Pipeline
  from greykite.common.constants import ACTUAL_COL
  from greykite.common.constants import ADJUSTMENT_DELTA_COL
  from greykite.common.constants import END_TIME_COL
  from greykite.common.constants import FRACTION_OUTSIDE_TOLERANCE
  from greykite.common.constants import METRIC_COL
  from greykite.common.constants import PREDICTED_COL
  from greykite.common.constants import QUANTILE_SUMMARY_COL
  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.constants import R2_null_model_score
  from greykite.common.evaluation import EvaluationMetricEnum
  from greykite.common.evaluation import add_finite_filter_to_scorer
  from greykite.common.evaluation import add_preaggregation_to_scorer
  from greykite.common.python_utils import assert_equal
  from greykite.common.python_utils import unique_elements_in_list
  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 CV_REPORT_METRICS_ALL
  from greykite.framework.constants import FRACTION_OUTSIDE_TOLERANCE_NAME
  from greykite.framework.input.univariate_time_series import UnivariateTimeSeries
  from greykite.framework.pipeline.pipeline import forecast_pipeline
  from greykite.framework.templates.prophet_template import ProphetTemplate
  from greykite.framework.utils.framework_testing_utils import check_forecast_pipeline_result
  from greykite.framework.utils.framework_testing_utils import mock_pipeline
  from greykite.sklearn.estimator.null_model import DummyEstimator
  from greykite.sklearn.estimator.prophet_estimator import ProphetEstimator
  from greykite.sklearn.estimator.silverkite_estimator import SilverkiteEstimator
  from greykite.sklearn.estimator.simple_silverkite_estimator import SimpleSilverkiteEstimator
  from greykite.sklearn.transform.column_selector import ColumnSelector
  from greykite.sklearn.transform.drop_degenerate_transformer import DropDegenerateTransformer
  from greykite.sklearn.transform.dtype_column_selector import DtypeColumnSelector
  from greykite.sklearn.transform.normalize_transformer import NormalizeTransformer
  from greykite.sklearn.transform.null_transformer import NullTransformer
  from greykite.sklearn.transform.pandas_feature_union import PandasFeatureUnion
  from greykite.sklearn.transform.zscore_outlier_transformer import ZscoreOutlierTransformer
label_desc: Use image node_id 22 for calling a global function with example usage: test_pipeline_end2end_predict() without return types