code: def test_start_end_dates(use_periods):
      endog = dta["infl"].copy()
      if use_periods:
          index_range = pd.period_range
      else:
  
          def index_range(*args, **kwargs):
              return pd.period_range(*args, **kwargs).to_timestamp(
                  freq="Q"
              )
  
          endog = endog.to_timestamp(freq="Q")
      mod = sarimax.SARIMAX(endog.iloc[:-1])
      res = mod.smooth([0.5, 1.0])
  
      # Default is the first out-of-sample period
      news = res.news(endog)
      desired = index_range(start="2009Q2", periods=1, freq="Q")
      assert_(news.total_impacts.index.equals(desired))
  
      # Start (dates), periods
      news = res.news(endog, start="2009Q1", periods=1)
      desired = index_range(start="2009Q1", periods=1, freq="Q")
      assert_(news.total_impacts.index.equals(desired))
      news = res.news(endog, start="2009Q1", periods=2)
      desired = index_range(start="2009Q1", periods=2, freq="Q")
      assert_(news.total_impacts.index.equals(desired))
  
      # Start (int), periods
      news = res.news(endog, start=mod.nobs - 1, periods=1)
      desired = index_range(start="2009Q2", periods=1, freq="Q")
      assert_(news.total_impacts.index.equals(desired))
      news = res.news(endog, start=mod.nobs - 2, periods=2)
      desired = index_range(start="2009Q1", periods=2, freq="Q")
      assert_(news.total_impacts.index.equals(desired))
  
      # End (dates), periods
      news = res.news(endog, end="2009Q1", periods=1)
      desired = index_range(end="2009Q1", periods=1, freq="Q")
      assert_(news.total_impacts.index.equals(desired))
      news = res.news(endog, end="2009Q1", periods=2)
      desired = index_range(end="2009Q1", periods=2, freq="Q")
      assert_(news.total_impacts.index.equals(desired))
  
      # End (int), periods
      news = res.news(endog, end=mod.nobs - 1, periods=1)
      desired = index_range(end="2009Q2", periods=1, freq="Q")
      assert_(news.total_impacts.index.equals(desired))
      news = res.news(endog, end=mod.nobs - 2, periods=2)
      desired = index_range(end="2009Q1", periods=2, freq="Q")
      assert_(news.total_impacts.index.equals(desired))
  
      # Start (dates), end (dates)
      news = res.news(endog, start="2009Q1", end="2009Q1")
      desired = index_range(start="2009Q1", end="2009Q1", freq="Q")
      assert_(news.total_impacts.index.equals(desired))
      news = res.news(endog, start="2009Q1", end="2009Q2")
      desired = index_range(start="2009Q1", end="2009Q2", freq="Q")
      assert_(news.total_impacts.index.equals(desired))
  
      # Start (dates), end (int)
      news = res.news(endog, start="2009Q1", end=mod.nobs - 2)
      desired = index_range(start="2009Q1", end="2009Q1", freq="Q")
      assert_(news.total_impacts.index.equals(desired))
      predicted = res.predict(start="2009Q1", end=mod.nobs - 2)
      assert_(news.total_impacts.index.equals(predicted.index))
      news = res.news(endog, start="2009Q1", end=mod.nobs - 1)
      desired = index_range(start="2009Q1", end="2009Q2", freq="Q")
      assert_(news.total_impacts.index.equals(desired))
      predicted = res.predict(start="2009Q1", end=mod.nobs - 1)
      assert_(news.total_impacts.index.equals(predicted.index))
  
      # Start (int), end (dates)
      news = res.news(endog, start=mod.nobs - 2, end="2009Q1")
      desired = index_range(start="2009Q1", end="2009Q1", freq="Q")
      assert_(news.total_impacts.index.equals(desired))
      predicted = res.predict(start=mod.nobs - 2, end="2009Q1")
      assert_(news.total_impacts.index.equals(predicted.index))
      news = res.news(endog, start=mod.nobs - 2, end="2009Q2")
      desired = index_range(start="2009Q1", end="2009Q2", freq="Q")
      assert_(news.total_impacts.index.equals(desired))
      predicted = res.predict(start=mod.nobs - 2, end="2009Q2")
      assert_(news.total_impacts.index.equals(predicted.index))
  
      # Negative indexes
      # Note that negative indexes are always computed relative to the updated
      # sample, which in this case is 1 observation more than is in `mod.nobs`
      total_nobs = len(endog)
      assert_equal(total_nobs, mod.nobs + 1)
  
      # Start (dates), end (int)
      desired = index_range(start="2009Q1", end="2009Q1", freq="Q")
      for end in [mod.nobs - 2, total_nobs - 3, -3]:
          news = res.news(endog, start="2009Q1", end=end)
          assert_(news.total_impacts.index.equals(desired))
          # Note: predict does not allow negative indexing
          if end > 0:
              predicted = res.predict(start="2009Q1", end=end)
              assert_(news.total_impacts.index.equals(predicted.index))
  
      # Start (int), end (dates)
      desired = index_range(start="2009Q1", end="2009Q1", freq="Q")
      for start in [mod.nobs - 2, total_nobs - 3, -3]:
          news = res.news(endog, start=start, end="2009Q1")
          assert_(news.total_impacts.index.equals(desired))
          # Note: predict does not allow negative indexing
          if end > 0:
              predicted = res.predict(start=start, end="2009Q1")
              assert_(news.total_impacts.index.equals(predicted.index))
  
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 14 for calling a global function with example usage: test_start_end_dates(use_periods) and returns: pd