code: def test_fit():
      # Test that fitting works regardless of the level of memory conservation
      # used
      endog = dta["infl"].iloc[:20]
      mod = sarimax.SARIMAX(
          endog, order=(1, 0, 0), concentrate_scale=True
      )
  
      res = mod.fit(disp=False)
  
      options_smooth = [
          "memory_no_forecast",
          "memory_no_filtered",
          "memory_no_likelihood",
          "memory_no_std_forecast",
      ]
      for option in options_smooth:
          mod.ssm.set_conserve_memory(0)
          setattr(mod.ssm, option, True)
          res2 = mod.fit(res.params, disp=False)
  
          # General check that smoothing results are available
          assert_allclose(
              res2.smoothed_state, res.smoothed_state, atol=1e-10
          )
  
          # Specific checks for each type
          if option == "memory_no_forecast":
              assert_(res2.forecasts is None)
              assert_(res2.forecasts_error is None)
              assert_(res2.forecasts_error_cov is None)
          else:
              assert_allclose(res2.forecasts, res.forecasts)
              assert_allclose(res2.forecasts_error, res.forecasts_error)
              assert_allclose(
                  res2.forecasts_error_cov, res.forecasts_error_cov
              )
  
          if option == "memory_no_filtered":
              assert_(res2.filtered_state is None)
              assert_(res2.filtered_state_cov is None)
          else:
              assert_allclose(res2.filtered_state, res.filtered_state)
              assert_allclose(
                  res2.filtered_state_cov, res.filtered_state_cov
              )
  
          assert_allclose(res2.llf, res.llf)
          if option == "memory_no_likelihood":
              assert_(res2.llf_obs is None)
          else:
              assert_allclose(res2.llf_obs, res.llf_obs)
  
          if option == "memory_no_std_forecast":
              assert_(res2.standardized_forecasts_error is None)
          else:
              assert_allclose(
                  res2.standardized_forecasts_error,
                  res.standardized_forecasts_error,
              )
  
      options_filter_only = [
          "memory_no_predicted",
          "memory_no_gain",
          "memory_no_smoothing",
          "memory_conserve",
      ]
      for option in options_filter_only[2:]:
          mod.ssm.set_conserve_memory(0)
          setattr(mod.ssm, option, True)
          res2 = mod.fit(res.params, disp=False)
  
          # General check that smoothing results are not available
          assert_(res2.smoothed_state is None)
  
          # Specific checks for each type
          if option in ["memory_no_predicted", "memory_conserve"]:
              assert_(res2.predicted_state_cov is None)
              if option == "memory_no_predicted":
                  assert_(res2.predicted_state is None)
          else:
              assert_allclose(res2.predicted_state, res.predicted_state)
              assert_allclose(
                  res2.predicted_state_cov, res.predicted_state_cov
              )
  
          if option in ["memory_no_gain", "memory_conserve"]:
              assert_(res2.filter_results._kalman_gain is None)
          else:
              assert_allclose(
                  res2.filter_results.kalman_gain,
                  res.filter_results.kalman_gain,
              )
  
file_path: statsmodels/statsmodels/tsa/statespace/tests/test_conserve_memory.py
imports: import numpy
  import pandas
  import pytest
  from numpy.testing import assert_equal, assert_allclose, assert_
  from statsmodels.datasets import macrodata
  from statsmodels.tsa.statespace import sarimax, varmax, dynamic_factor
  from statsmodels.tsa.statespace.kalman_filter import MEMORY_NO_FORECAST_MEAN, MEMORY_NO_FORECAST_COV, MEMORY_NO_PREDICTED_MEAN, MEMORY_NO_PREDICTED_COV, MEMORY_NO_PREDICTED, MEMORY_NO_SMOOTHING, MEMORY_NO_GAIN, MEMORY_CONSERVE
label_desc: Use image node_id 5 for calling a global function with example usage: test_fit() without return types