code: def test_smoothed_decomposition_sarimax(
      use_exog, trend, concentrate_scale, measurement_error
  ):
      endog = np.array([[0.2, np.nan, 1.2, -0.3, -1.5]]).T
      exog = np.array([2, 5.3, -1, 3.4, 0.0]) if use_exog else None
  
      trend_params = [0.1]
      ar_params = [0.5]
      exog_params = [1.4]
      meas_err_params = [1.2]
      cov_params = [0.8]
  
      params = []
      if trend in ["c", "t"]:
          params += trend_params
      if use_exog:
          params += exog_params
      params += ar_params
      if measurement_error:
          params += meas_err_params
      if not concentrate_scale:
          params += cov_params
  
      # Fit the models
      mod = sarimax.SARIMAX(
          endog,
          order=(1, 0, 0),
          trend=trend,
          exog=exog if use_exog else None,
          concentrate_scale=concentrate_scale,
          measurement_error=measurement_error,
      )
      prior_mean = np.array([-0.4])
      prior_cov = np.eye(1) * 1.2
      mod.ssm.initialize_known(prior_mean, prior_cov)
      res = mod.smooth(params)
  
      # Check smoothed state
  
      # Get the decomposition of the smoothed state
      cd, coi, csi, cp = res.get_smoothed_decomposition(
          decomposition_of="smoothed_state"
      )
  
      # Sum across contributions (i.e. from observations at each time period and
      # from the initial state)
      css = (cd + coi).sum(axis=1) + csi.sum(axis=1) + cp.sum(axis=1)
      css = css.unstack(level="state_to").values
  
      # Summing up all contributions should yield the actual smoothed state,
      # so the smoothed state vector is the desired result of this test
      ss = np.array(res.states.smoothed)
  
      assert_allclose(css, ss, atol=1e-12)
  
      # Check smoothed signal
  
      # Use the summed state contributions and multiply by the design matrix
      # to get the smoothed signal
      csf = (
          (css.T * mod["design"][:, :, None]).sum(axis=1)
          + mod["obs_intercept"]
      ).T
  
      # Summing up all contributions should yield the smoothed prediction of
      # the observed variables
      s_sig = res.predict(information_set="smoothed", signal_only=True)
      sf = res.predict(information_set="smoothed", signal_only=False)
  
      assert_allclose(csf[:, 0], sf)
  
      # Now check the smoothed signal against the sum computed from the
      # decomposed smoothed signal
      cd, coi, csi, cp = res.get_smoothed_decomposition(
          decomposition_of="smoothed_signal"
      )
  
      # Sum across contributions (i.e. from observations and intercepts at each
      # time period and from the initial state) to get the smoothed signal
      cs_sig = (cd + coi).sum(axis=1) + csi.sum(axis=1) + cp.sum(axis=1)
      cs_sig = cs_sig.unstack(level="variable_to").values
  
      assert_allclose(cs_sig[:, 0], s_sig, atol=1e-12)
  
      # Add in the observation intercept to get the smoothed forecast
      csf = cs_sig + mod["obs_intercept"].T
  
      assert_allclose(csf[:, 0], sf)
  
file_path: statsmodels/statsmodels/tsa/statespace/tests/test_decompose.py
imports: import pytest
  import numpy
  import pandas
  from numpy.testing import assert_allclose
  from statsmodels import datasets
  from statsmodels.tsa.statespace import sarimax, varmax, dynamic_factor_mq
  from statsmodels.tsa.statespace.tests.test_impulse_responses import TVSS
label_desc: Use image node_id 1 for calling a global function with example usage: test_smoothed_decomposition_sarimax(use_exog, trend, concentrate_scale, measurement_error) without return types