code: def test_uncertainty(df, forecast_config):
      """Tests the uncertainty methods."""
  
      # Tests no coverage and no uncertainty, there is no uncertainty.
  
      forecaster = Forecaster()
      forecast_result = forecaster.run_forecast_config(
          df=df, config=forecast_config
      )
      assert PREDICTED_LOWER_COL not in forecast_result.backtest.df_test
      assert PREDICTED_LOWER_COL not in forecast_result.forecast.df_test
  
      # Tests coverage and no uncertainty, there is uncertainty.
      forecast_config.coverage = 0.99
      forecaster = Forecaster()
      forecast_result = forecaster.run_forecast_config(
          df=df, config=forecast_config
      )
      assert PREDICTED_LOWER_COL in forecast_result.backtest.df_test
      assert PREDICTED_LOWER_COL in forecast_result.forecast.df_test
      assert forecast_result.model[-1].coverage == 0.99
      # Default method is used when coverage is given but ``uncertainty_dict`` is not given.
      assert (
          forecast_result.model[-1].uncertainty_model.UNCERTAINTY_METHOD
          == UncertaintyMethodEnum.simple_conditional_residuals.name
      )
      last_interval_width_99 = (
          forecast_result.forecast.df[PREDICTED_UPPER_COL].iloc[-1]
          - forecast_result.forecast.df[PREDICTED_LOWER_COL].iloc[-1]
      )
  
      # Tests coverage and uncertainty, there is uncertainty.
      forecast_config.model_components_param.uncertainty = dict(
          uncertainty_dict=dict(
              uncertainty_method=UncertaintyMethodEnum.simple_conditional_residuals.name,
              params=dict(conditional_cols=["dow"]),
          )
      )
      forecaster = Forecaster()
      forecast_result = forecaster.run_forecast_config(
          df=df, config=forecast_config
      )
      assert PREDICTED_LOWER_COL in forecast_result.backtest.df_test
      assert PREDICTED_LOWER_COL in forecast_result.forecast.df_test
      assert forecast_result.model[-1].coverage == 0.99
      # The last 2 days intervals should have different lengths due to conditioning on "dow".
      last_day_interval_width_99 = (
          forecast_result.forecast.df[PREDICTED_UPPER_COL].iloc[-1]
          - forecast_result.forecast.df[PREDICTED_LOWER_COL].iloc[-1]
      )
      second_last_day_interval_width_99 = (
          forecast_result.forecast.df[PREDICTED_UPPER_COL].iloc[-25]
          - forecast_result.forecast.df[PREDICTED_LOWER_COL].iloc[-25]
      )
      assert (
          last_day_interval_width_99
          != second_last_day_interval_width_99
      )
  
      # Tests 95% coverage has narrower interval.
      forecast_config.coverage = 0.95
      forecast_config.model_components_param.uncertainty = dict(
          uncertainty_dict=dict(
              uncertainty_method=UncertaintyMethodEnum.simple_conditional_residuals.name,
              params=dict(),
          )
      )
      forecaster = Forecaster()
      forecast_result = forecaster.run_forecast_config(
          df=df, config=forecast_config
      )
      assert PREDICTED_LOWER_COL in forecast_result.backtest.df_test
      assert PREDICTED_LOWER_COL in forecast_result.forecast.df_test
      assert forecast_result.model[-1].coverage == 0.95
      # 95 interval is narrower than 99 interval.
      last_interval_width_95 = (
          forecast_result.forecast.df[PREDICTED_UPPER_COL].iloc[-1]
          - forecast_result.forecast.df[PREDICTED_LOWER_COL].iloc[-1]
      )
      assert last_interval_width_99 > last_interval_width_95
  
imports: import datetime
  import numpy
  import pytest
  from testfixtures import LogCapture
  from greykite.common.constants import LOGGER_NAME
  from greykite.common.constants import PREDICTED_COL
  from greykite.common.constants import PREDICTED_LOWER_COL
  from greykite.common.constants import PREDICTED_UPPER_COL
  from greykite.common.constants import TIME_COL
  from greykite.common.constants import VALUE_COL
  from greykite.common.testing_utils import generate_df_for_tests
  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.multistage_forecast_template import MultistageForecastTemplate
  from greykite.framework.templates.multistage_forecast_template_config import SILVERKITE_TWO_STAGE
  from greykite.framework.templates.multistage_forecast_template_config import MultistageForecastTemplateConfig
  from greykite.framework.templates.simple_silverkite_template import SimpleSilverkiteTemplate
  from greykite.sklearn.estimator.simple_silverkite_estimator import SimpleSilverkiteEstimator
  from greykite.sklearn.uncertainty.uncertainty_methods import UncertaintyMethodEnum
label_desc: Use image node_id 20 for calling a global function with example usage: test_uncertainty(df, forecast_config) without return types