code: def test_forecast_exog():
      # Test forecasting with various shapes of `exog`
      nobs = 100
      endog = np.ones(nobs) * 2.0
      exog = np.ones(nobs)
  
      mod = UnobservedComponents(endog, "irregular", exog=exog)
      res = mod.smooth([1.0, 2.0])
  
      # 1-step-ahead, valid
      exog_fcast_scalar = 1.0
      exog_fcast_1dim = np.ones(1)
      exog_fcast_2dim = np.ones((1, 1))
  
      assert_allclose(res.forecast(1, exog=exog_fcast_scalar), 2.0)
      assert_allclose(res.forecast(1, exog=exog_fcast_1dim), 2.0)
      assert_allclose(res.forecast(1, exog=exog_fcast_2dim), 2.0)
  
      # h-steps-ahead, valid
      h = 10
      exog_fcast_1dim = np.ones(h)
      exog_fcast_2dim = np.ones((h, 1))
  
      assert_allclose(res.forecast(h, exog=exog_fcast_1dim), 2.0)
      assert_allclose(res.forecast(h, exog=exog_fcast_2dim), 2.0)
  
      # h-steps-ahead, invalid
      assert_raises(ValueError, res.forecast, h, exog=1.0)
      assert_raises(ValueError, res.forecast, h, exog=[1, 2])
      assert_raises(ValueError, res.forecast, h, exog=np.ones((h, 2)))
  
imports: import warnings
  import numpy
  from numpy.testing import assert_equal, assert_allclose, assert_raises
  import pandas
  import pytest
  from statsmodels.datasets import macrodata
  from statsmodels.tools.sm_exceptions import SpecificationWarning
  from statsmodels.tsa.statespace import structural
  from statsmodels.tsa.statespace.structural import UnobservedComponents
  from statsmodels.tsa.statespace.tests.results import results_structural
label_desc: Use image node_id 29 for calling a global function with example usage: test_forecast_exog() without return types