code: def test_dynamic_factor_end_time_varying_exog_noshocks():
      # Test simulating values from the end of a time-varying dynamic factor
      # model with exogenous inputs
      # In this test, we suppress randomness by setting the shocks to zeros
      endog = np.arange(1, 21).reshape(10, 2)
      exog = np.arange(1, 21) ** 2
      mod = dynamic_factor.DynamicFactor(
          endog, k_factors=1, factor_order=1, exog=exog[:10]
      )
      mod.ssm.filter_univariate = True
      res = mod.filter([1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
  
      nsimulations = 10
      measurement_shocks = np.zeros((nsimulations, mod.k_endog))
      state_shocks = np.zeros((nsimulations, mod.k_states))
      initial_state = res.predicted_state[..., -1]
  
      # Simulation
      actual = res.simulate(
          nsimulations,
          exog=exog[10:],
          anchor="end",
          measurement_shocks=measurement_shocks,
          state_shocks=state_shocks,
          initial_state=initial_state,
      )
  
      # Construct the simulation directly
      desired = np.zeros((nsimulations, mod.k_endog))
      desired[0] = initial_state
      for i in range(1, nsimulations):
          desired[i] = desired[i - 1] + state_shocks[i - 1]
      desired = desired + measurement_shocks + exog[10:, None]
      assert_allclose(actual, desired)
  
      # Test using the model versus the results class
      mod_actual = mod.simulate(
          res.params,
          nsimulations,
          exog=exog[10:],
          anchor="end",
          measurement_shocks=measurement_shocks,
          state_shocks=state_shocks,
          initial_state=initial_state,
      )
  
      assert_allclose(mod_actual, desired)
  
      # Alternatively, since we've shut down the shocks, we can compare against
      # the forecast values
      assert_allclose(
          actual, res.forecast(nsimulations, exog=exog[10:])
      )
  
imports: from statsmodels.compat.pandas import MONTH_END
  import numpy
  from numpy.testing import assert_, assert_allclose, assert_equal
  import pandas
  import pytest
  from scipy.signal import lfilter
  from statsmodels.tools.sm_exceptions import EstimationWarning, SpecificationWarning
  from statsmodels.tsa.statespace import dynamic_factor, sarimax, structural, varmax
  from .test_impulse_responses import TVSS
label_desc: Use image node_id 32 for calling a global function with example usage: test_dynamic_factor_end_time_varying_exog_noshocks() without return types