code: def test_forecast_result_one_by_one(df):
      forecaster = Forecaster()
      # Run the forecast
      result = forecaster.run_forecast_config(
          df=df,  # includes the regressor
          config=ForecastConfig(
              model_template=ModelTemplateEnum.SILVERKITE.name,
              forecast_horizon=7,
              coverage=0.8,
              metadata_param=MetadataParam(
                  time_col="ts", value_col="y", freq="D"
              ),
              evaluation_period_param=EvaluationPeriodParam(
                  cv_max_splits=1,
                  cv_horizon=7,
                  test_horizon=7,
                  cv_min_train_periods=80,
              ),
              computation_param=ComputationParam(n_jobs=-1),
              model_components_param=ModelComponentsParam(
                  custom={
                      "fit_algorithm_dict": {"fit_algorithm": "linear"}
                  },
                  autoregression={"autoreg_dict": "auto"},
              ),
              forecast_one_by_one=[2, 5],
          ),
      )
      dump_obj(
          result,
          dir_name="onebyone",
          dump_design_info=True,
          overwrite_exist_dir=True,
      )
      result_rec = load_obj(dir_name="onebyone", load_design_info=True)
      recursive_rm_dir("onebyone")
  
      # Tests loaded results
      # Grid search cv results
      assert_equal(
          summarize_grid_search_results(result.grid_search),
          summarize_grid_search_results(result_rec.grid_search),
      )
      # Grid search attributes
      for key in result.grid_search.__dict__.keys():
          if key not in [
              "scoring",
              "estimator",
              "refit",
              "cv",
              "error_score",
              "cv_results_",
              "scorer_",
              "best_estimator_",
          ]:
              assert_equal(
                  result.grid_search.__dict__[key],
                  result_rec.grid_search.__dict__[key],
              )
  
      # Model
      assert_equal(
          result.model[-1].predict(df), result_rec.model[-1].predict(df)
      )
      assert (
          result.model[-1].estimators[0].model_dict["x_design_info"]
          is not None
      )
      # Model: estimator
      for key in result.model[-1].estimators[0].__dict__.keys():
          if key not in [
              "score_func",
              "silverkite",
              "silverkite_diagnostics",
              "model_dict",
          ]:
              assert_equal(
                  result.model[-1].estimators[0].__dict__[key],
                  result_rec.model[-1].estimators[0].__dict__[key],
              )
      assert_equal(
          inspect.getsource(
              result.model[-1].estimators[0].__dict__["score_func"]
          ),
          inspect.getsource(
              result_rec.model[-1].estimators[0].__dict__["score_func"]
          ),
      )
      # Model: estimator/model_dict
      for key in result.model[-1].estimators[0].model_dict.keys():
          # Functions and classes are not testable.
          if key not in [
              "x_design_info",
              "fs_func",
              "ml_model",
              "plt_pred",
              "autoreg_dict",
              "changepoint_detector",
              "autoreg_func",
              "normalize_df_func",
          ]:
              assert_equal(
                  result.model[-1].estimators[0].model_dict[key],
                  result_rec.model[-1].estimators[0].model_dict[key],
              )
          # Tests function source code.
          elif key in [
              "fs_func",
              "plt_pred",
              "autoreg_func",
              "normalize_df_func",
          ]:
              assert_equal(
                  inspect.getsource(
                      result.model[-1].estimators[0].model_dict[key]
                  ),
                  inspect.getsource(
                      result_rec.model[-1].estimators[0].model_dict[key]
                  ),
              )
      # Model: estimator/model_dict/autoreg_dict
      for key in (
          result.model[-1]
          .estimators[0]
          .model_dict["autoreg_dict"]
          .keys()
      ):
          if key not in ["series_na_fill_func"]:
              assert_equal(
                  result.model[-1]
                  .estimators[0]
                  .model_dict["autoreg_dict"][key],
                  result_rec.model[-1]
                  .estimators[0]
                  .model_dict["autoreg_dict"][key],
              )
      assert_equal(
          inspect.getsource(
              result.model[-1]
              .estimators[0]
              .model_dict["autoreg_dict"]["series_na_fill_func"]
          ),
          inspect.getsource(
              result_rec.model[-1]
              .estimators[0]
              .model_dict["autoreg_dict"]["series_na_fill_func"]
          ),
      )
  
      # Forecast
      assert_equal(
          result.forecast.estimator.predict(df),
          result_rec.forecast.estimator.predict(df),
      )
      assert (
          result.forecast.estimator.estimators[0].model_dict[
              "x_design_info"
          ]
          is not None
      )
      # Forecast: attributes
      for key in result.forecast.__dict__.keys():
          if key not in ["r2_loss_function", "estimator"]:
              assert_equal(
                  result.forecast.__dict__[key],
                  result_rec.forecast.__dict__[key],
              )
      assert_equal(
          inspect.getsource(
              result.forecast.__dict__["r2_loss_function"]
          ),
          inspect.getsource(
              result_rec.forecast.__dict__["r2_loss_function"]
          ),
      )
      # Forecast: estimator
      for key in result.forecast.estimator.estimators[
          0
      ].__dict__.keys():
          if key not in [
              "score_func",
              "silverkite",
              "silverkite_diagnostics",
              "model_dict",
          ]:
              assert_equal(
                  result.forecast.estimator.estimators[0].__dict__[key],
                  result_rec.forecast.estimator.estimators[0].__dict__[
                      key
                  ],
              )
      assert_equal(
          inspect.getsource(
              result.forecast.estimator.estimators[0].__dict__[
                  "score_func"
              ]
          ),
          inspect.getsource(
              result_rec.forecast.estimator.estimators[0].__dict__[
                  "score_func"
              ]
          ),
      )
      # Model: estimator/model_dict
      for key in result.forecast.estimator.estimators[
          0
      ].model_dict.keys():
          # Functions and classes are not testable.
          if key not in [
              "x_design_info",
              "fs_func",
              "ml_model",
              "plt_pred",
              "autoreg_dict",
              "changepoint_detector",
              "autoreg_func",
              "normalize_df_func",
          ]:
              assert_equal(
                  result.forecast.estimator.estimators[0].model_dict[
                      key
                  ],
                  result_rec.forecast.estimator.estimators[
                      0
                  ].model_dict[key],
              )
          # Tests function source code.
          elif key in [
              "fs_func",
              "plt_pred",
              "autoreg_func",
              "normalize_df_func",
          ]:
              assert_equal(
                  inspect.getsource(
                      result.forecast.estimator.estimators[
                          0
                      ].model_dict[key]
                  ),
                  inspect.getsource(
                      result_rec.forecast.estimator.estimators[
                          0
                      ].model_dict[key]
                  ),
              )
      # Model: estimator/model_dict/autoreg_dict
      for key in (
          result.forecast.estimator.estimators[0]
          .model_dict["autoreg_dict"]
          .keys()
      ):
          if key not in ["series_na_fill_func"]:
              assert_equal(
                  result.forecast.estimator.estimators[0].model_dict[
                      "autoreg_dict"
                  ][key],
                  result_rec.forecast.estimator.estimators[
                      0
                  ].model_dict["autoreg_dict"][key],
              )
      assert_equal(
          inspect.getsource(
              result.forecast.estimator.estimators[0].model_dict[
                  "autoreg_dict"
              ]["series_na_fill_func"]
          ),
          inspect.getsource(
              result_rec.forecast.estimator.estimators[0].model_dict[
                  "autoreg_dict"
              ]["series_na_fill_func"]
          ),
      )
  
      # Backtest
      assert_equal(
          result.backtest.estimator.predict(df),
          result_rec.backtest.estimator.predict(df),
      )
      assert (
          result.backtest.estimator.estimators[0].model_dict[
              "x_design_info"
          ]
          is not None
      )
      # Forecast: attributes
      for key in result.backtest.__dict__.keys():
          if key not in ["r2_loss_function", "estimator"]:
              assert_equal(
                  result.backtest.__dict__[key],
                  result_rec.backtest.__dict__[key],
              )
      assert_equal(
          inspect.getsource(
              result.backtest.__dict__["r2_loss_function"]
          ),
          inspect.getsource(
              result_rec.backtest.__dict__["r2_loss_function"]
          ),
      )
      # Forecast: estimator
      for key in result.backtest.estimator.estimators[
          0
      ].__dict__.keys():
          if key not in [
              "score_func",
              "silverkite",
              "silverkite_diagnostics",
              "model_dict",
          ]:
              assert_equal(
                  result.backtest.estimator.estimators[0].__dict__[key],
                  result_rec.backtest.estimator.estimators[0].__dict__[
                      key
                  ],
              )
      assert_equal(
          inspect.getsource(
              result.backtest.estimator.estimators[0].__dict__[
                  "score_func"
              ]
          ),
          inspect.getsource(
              result_rec.backtest.estimator.estimators[0].__dict__[
                  "score_func"
              ]
          ),
      )
      # Model: estimator/model_dict
      for key in result.backtest.estimator.estimators[
          0
      ].model_dict.keys():
          # Functions and classes are not testable.
          if key not in [
              "x_design_info",
              "fs_func",
              "ml_model",
              "plt_pred",
              "autoreg_dict",
              "changepoint_detector",
              "autoreg_func",
              "normalize_df_func",
          ]:
              assert_equal(
                  result.backtest.estimator.estimators[0].model_dict[
                      key
                  ],
                  result_rec.backtest.estimator.estimators[
                      0
                  ].model_dict[key],
              )
          # Tests function source code.
          elif key in [
              "fs_func",
              "plt_pred",
              "autoreg_func",
              "normalize_df_func",
          ]:
              assert_equal(
                  inspect.getsource(
                      result.backtest.estimator.estimators[
                          0
                      ].model_dict[key]
                  ),
                  inspect.getsource(
                      result_rec.backtest.estimator.estimators[
                          0
                      ].model_dict[key]
                  ),
              )
      # Model: estimator/model_dict/autoreg_dict
      for key in (
          result.backtest.estimator.estimators[0]
          .model_dict["autoreg_dict"]
          .keys()
      ):
          if key not in ["series_na_fill_func"]:
              assert_equal(
                  result.backtest.estimator.estimators[0].model_dict[
                      "autoreg_dict"
                  ][key],
                  result_rec.backtest.estimator.estimators[
                      0
                  ].model_dict["autoreg_dict"][key],
              )
      assert_equal(
          inspect.getsource(
              result.backtest.estimator.estimators[0].model_dict[
                  "autoreg_dict"
              ]["series_na_fill_func"]
          ),
          inspect.getsource(
              result_rec.backtest.estimator.estimators[0].model_dict[
                  "autoreg_dict"
              ]["series_na_fill_func"]
          ),
      )
  
      # Timeseries
      for key in result.timeseries.__dict__.keys():
          assert_equal(
              result.timeseries.__dict__[key],
              result_rec.timeseries.__dict__[key],
          )
  
imports: import inspect
  import os
  import sys
  from collections import OrderedDict
  import pytest
  from greykite.common.python_utils import assert_equal
  from greykite.common.testing_utils import generate_df_for_tests
  from greykite.framework.templates.autogen.forecast_config import ComputationParam
  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.pickle_utils import dump_obj
  from greykite.framework.templates.pickle_utils import load_obj
  from greykite.framework.templates.pickle_utils import recursive_rm_dir
  from greykite.framework.utils.result_summary import summarize_grid_search_results
label_desc: Use image node_id 11 for calling a global function with example usage: test_forecast_result_one_by_one(df) without return types