code: def test_varmax_time_invariant(revisions, updates):
      # Construct previous and updated datasets
      endog = dta[["realgdp", "unemp"]].copy()
      endog["realgdp"] = np.log(endog["realgdp"]).diff() * 400
      endog = endog.iloc[1:]
      comparison_type = None
      if updates:
          endog1 = endog.loc[:"2009Q2"].copy()
          endog2 = endog.loc[:"2009Q3"].copy()
      else:
          endog1 = endog.loc[:"2009Q3"].copy()
          endog2 = endog.loc[:"2009Q3"].copy()
          # Without updates and without NaN values, we need to specify that
          # the type of the comparison object that we're passing is "updated"
          comparison_type = "updated"
      if revisions:
          # TODO: add test for only one of the variables revising?
          endog1.iloc[-1] = 0.0
  
      # Get the previous results object and compute the news
      mod = varmax.VARMAX(endog1, trend="n")
      params = np.r_[0.5, 0.1, 0.2, 0.9, 1.0, 0.1, 1.1]
      res = mod.smooth(params)
      news = res.news(
          endog2,
          start="2009Q2",
          end="2010Q1",
          comparison_type=comparison_type,
      )
  
      # Compute the true values for each combination of (revsions, updates)
      impact_dates = pd.period_range(
          start="2009Q2", end="2010Q1", freq="Q"
      )
      impacted_variables = ["realgdp", "unemp"]
  
      # Matrix powers of transition matrix
      Z = np.zeros((2, 2))
      T0 = np.eye(2)
      T1 = mod["transition"]
      T2 = T1 @ T1
      T3 = T1 @ T2
  
      # Revisions
      if revisions and updates:
          revisions_index = pd.MultiIndex.from_product(
              [endog1.index[-1:], ["realgdp", "unemp"]],
              names=["revision date", "revised variable"],
          )
          # If we have updates, the revision is to 2009Q2
          # Note: this ".values" and all of those below are only required for
          # Pandas = 0.23, and can be removed once that is no longer a supported
          # dependency
          tmp = endog2.iloc[-2].values
          revision_impacts = np.c_[
              T0 @ tmp, T1 @ tmp, T2 @ tmp, T3 @ tmp
          ].T
      elif revisions:
          revisions_index = pd.MultiIndex.from_product(
              [endog1.index[-1:], ["realgdp", "unemp"]],
              names=["revision date", "revised variable"],
          )
          # With no updates, the revision is to 2009Q3
          tmp = endog2.iloc[-1].values
          revision_impacts = np.c_[
              Z @ tmp, T0 @ tmp, T1 @ tmp, T2 @ tmp
          ].T
      else:
          revisions_index = pd.MultiIndex.from_product(
              [[], []], names=["revision date", "revised variable"]
          )
          revision_impacts = None
  
      # Impact forecasts
      if updates:
          tmp = endog1.iloc[-1].values
          prev_impacted_forecasts = np.c_[
              T0 @ tmp, T1 @ tmp, T2 @ tmp, T3 @ tmp
          ].T
          tmp = endog2.iloc[-2].values
          rev_impacted_forecasts = np.c_[
              T0 @ tmp, T1 @ tmp, T2 @ tmp, T3 @ tmp
          ].T
      else:
          tmp = endog1.iloc[-1].values
          prev_impacted_forecasts = np.c_[
              T0 @ endog1.iloc[-2], T0 @ tmp, T1 @ tmp, T2 @ tmp
          ].T
          tmp = endog2.iloc[-1].values
          rev_impacted_forecasts = np.c_[
              T0 @ endog2.iloc[-2], T0 @ tmp, T1 @ tmp, T2 @ tmp
          ].T
      tmp = endog2.iloc[-1].values
      post_impacted_forecasts = np.c_[
          T0 @ endog2.iloc[-2], T0 @ tmp, T1 @ tmp, T2 @ tmp
      ].T
  
      # Updates
      if updates:
          updates_index = pd.MultiIndex.from_product(
              [
                  pd.period_range(start="2009Q3", periods=1, freq="Q"),
                  ["realgdp", "unemp"],
              ],
              names=["update date", "updated variable"],
          )
          update_impacts = (
              post_impacted_forecasts - rev_impacted_forecasts
          )
      else:
          updates_index = pd.MultiIndex.from_product(
              [[], []], names=["update date", "updated variable"]
          )
          update_impacts = None
  
      # News
      if updates:
          # Note: update_forecasts is created using the endog2 dataset even if
          # there were revisions, because it should be computed after revisions
          # have already been taken into account
          update_forecasts = T1 @ endog2.loc["2009Q2"].values
          update_realized = endog2.loc["2009Q3"].values
          news_desired = [
              update_realized[i] - update_forecasts[i]
              for i in range(len(update_forecasts))
          ]
          columns = pd.MultiIndex.from_product(
              [impact_dates, impacted_variables],
              names=["impact dates", "impacted variables"],
          )
          weights = pd.DataFrame(
              np.zeros((2, 8)), index=updates_index, columns=columns
          )
          weights.loc[:, "2009Q2"] = Z
          weights.loc[:, "2009Q3"] = T0
          weights.loc[:, "2009Q4"] = T1.T
          weights.loc[:, "2010Q1"] = T2.T
      else:
          update_forecasts = pd.Series([], dtype=np.float64)
          update_realized = pd.Series([], dtype=np.float64)
          news_desired = pd.Series([], dtype=np.float64)
          weights = pd.DataFrame(np.zeros((0, 8)))
  
      # Run unit tests
      check_news(
          news,
          revisions,
          updates,
          impact_dates,
          impacted_variables,
          revisions_index,
          updates_index,
          revision_impacts,
          update_impacts,
          prev_impacted_forecasts,
          post_impacted_forecasts,
          update_forecasts,
          update_realized,
          news_desired,
          weights,
      )
  
imports: from statsmodels.compat.pandas import FUTURE_STACK, assert_frame_equal, assert_series_equal
  import numpy
  from numpy.testing import assert_, assert_allclose, assert_equal
  import pandas
  import pytest
  from statsmodels import datasets
  from statsmodels.tsa.statespace import dynamic_factor, sarimax, structural, varmax
label_desc: Use image node_id 9 for calling a global function with example usage: test_varmax_time_invariant(revisions, updates) without return types