code: def check_output(res_chand, res_orig, memory_conserve=False):
      # Test loglike
      params = res_orig.params
      assert_allclose(res_chand.llf, res_orig.llf)
      assert_allclose(
          res_chand.model.score_obs(params),
          res_orig.model.score_obs(params),
          rtol=5e-5,
          atol=5e-6,
      )
  
      # Test state space representation matrices
      for name in res_chand.model.ssm.shapes:
          if name == "obs":
              continue
          assert_allclose(
              getattr(res_chand.filter_results, name),
              getattr(res_orig.filter_results, name),
          )
  
      # Test filter / smoother output
      filter_attr = [
          "predicted_state",
          "filtered_state",
          "forecasts",
          "forecasts_error",
      ]
      # Can only check kalman gain if we didn't use memory conservation
      if not memory_conserve:
          filter_attr += ["kalman_gain"]
  
      for name in filter_attr:
          actual = getattr(res_chand.filter_results, name)
          desired = getattr(res_orig.filter_results, name)
          assert_allclose(actual, desired, atol=1e-12)
  
      filter_attr_burn = ["predicted_state_cov", "filtered_state_cov"]
  
      # Can only check kalman gain if we didn't use memory conservation
      if not memory_conserve:
          filter_attr += [
              "standardized_forecasts_error",
              "tmp1",
              "tmp2",
              "tmp3",
              "tmp4",
          ]
  
      for name in filter_attr_burn:
          actual = getattr(res_chand.filter_results, name)
          desired = getattr(res_orig.filter_results, name)
          assert_allclose(actual, desired, atol=1e-12)
  
      if not memory_conserve:
          smoothed_attr = [
              "smoothed_state",
              "smoothed_state_cov",
              "smoothed_state_autocov",
              "smoothed_state_disturbance",
              "smoothed_state_disturbance_cov",
              "smoothed_measurement_disturbance",
              "smoothed_measurement_disturbance_cov",
              "scaled_smoothed_estimator",
              "scaled_smoothed_estimator_cov",
              "smoothing_error",
              "smoothed_forecasts",
              "smoothed_forecasts_error",
              "smoothed_forecasts_error_cov",
          ]
  
          for name in smoothed_attr:
              actual = getattr(res_chand.filter_results, name)
              desired = getattr(res_orig.filter_results, name)
              assert_allclose(actual, desired, atol=1e-12)
  
      # Test prediction output
      nobs = res_chand.model.nobs
      if not memory_conserve:
          pred_chand = res_chand.get_prediction(
              start=10, end=nobs + 50, dynamic=40
          )
          pred_orig = res_chand.get_prediction(
              start=10, end=nobs + 50, dynamic=40
          )
      else:
          # In the memory conservation case, we can't do dynamic prediction
          pred_chand = res_chand.get_prediction(start=10, end=nobs + 50)
          pred_orig = res_chand.get_prediction(start=10, end=nobs + 50)
  
      assert_allclose(
          pred_chand.predicted_mean, pred_orig.predicted_mean
      )
      assert_allclose(pred_chand.se_mean, pred_orig.se_mean)
  
file_path: statsmodels/statsmodels/tsa/statespace/tests/test_chandrasekhar.py
imports: import numpy
  import pandas
  from .results import results_varmax
  from statsmodels.tsa.statespace import sarimax, varmax
  from statsmodels.tsa.statespace.kalman_filter import MEMORY_CONSERVE, MEMORY_NO_LIKELIHOOD
  from numpy.testing import assert_allclose
  import pytest
label_desc: Use image node_id 1 for calling a global function with example usage: check_output(res_chand, res_orig, memory_conserve) without return types