code: def _compute_smoothed_state_weights(
      ssm,
      compute_t=None,
      compute_j=None,
      compute_prior_weights=None,
      scale=1.0,
  ):
      # Get references to the Cython objects
      _model = ssm._statespace
      _kfilter = ssm._kalman_filter
      _smoother = ssm._kalman_smoother
  
      # Determine the appropriate function for the dtype
      func = prefix_compute_smoothed_state_weights_map[ssm.prefix]
  
      # Handle compute_t and compute_j indexes
      if compute_t is None:
          compute_t = np.arange(ssm.nobs)
      if compute_j is None:
          compute_j = np.arange(ssm.nobs)
      compute_t = np.unique(np.atleast_1d(compute_t).astype(np.int32))
      compute_t.sort()
      compute_j = np.unique(np.atleast_1d(compute_j).astype(np.int32))
      compute_j.sort()
  
      # Default setting for computing the prior weights
      if compute_prior_weights is None:
          compute_prior_weights = compute_j[0] == 0
      # Validate that compute_prior_weights is valid
      if compute_prior_weights and compute_j[0] != 0:
          raise ValueError(
              "If `compute_prior_weights` is set to True, then"
              " `compute_j` must include the time period 0."
          )
  
      # Compute the weights
      weights, state_intercept_weights, prior_weights, _ = func(
          _smoother,
          _kfilter,
          _model,
          compute_t,
          compute_j,
          scale,
          bool(compute_prior_weights),
      )
  
      # Re-order missing entries correctly and transpose to the appropriate
      # shape
      t0 = min(compute_t[0], compute_j[0])
      missing = np.isnan(ssm.endog[:, t0:])
      if np.any(missing):
          shape = weights.shape
          # Transpose m, p, t, j, -> t, m, p, j so that we can use the
          # `reorder_missing_matrix` function
          weights = np.asfortranarray(
              weights.transpose(2, 0, 1, 3).reshape(
                  shape[2] * shape[0], shape[1], shape[3], order="C"
              )
          )
          missing = np.asfortranarray(missing.astype(np.int32))
          reorder_missing_matrix(
              weights, missing, reorder_cols=True, inplace=True
          )
          # Transpose t, m, p, j -> t, j, m, p,
          weights = weights.reshape(
              shape[2], shape[0], shape[1], shape[3]
          ).transpose(0, 3, 1, 2)
      else:
          # Transpose m, p, t, j -> t, j, m, p
          weights = weights.transpose(2, 3, 0, 1)
  
      # Transpose m, l, t, j -> t, j, m, l
      state_intercept_weights = state_intercept_weights.transpose(
          2, 3, 0, 1
      )
  
      # Transpose m, l, t -> t, m, l
      prior_weights = prior_weights.transpose(2, 0, 1)
  
      # Subset to the actual computed t, j elements
      ix_tj = np.ix_(compute_t - t0, compute_j - t0)
      weights = weights[ix_tj]
      state_intercept_weights = state_intercept_weights[ix_tj]
      if compute_prior_weights:
          prior_weights = prior_weights[compute_t - t0]
  
      return weights, state_intercept_weights, prior_weights
  
imports: import numpy
  from scipy.linalg import solve_sylvester
  import pandas
  from statsmodels.compat.pandas import Appender
  from statsmodels.tools.data import _is_using_pandas
  from scipy.linalg.blas import find_best_blas_type
  from .None import _initialization, _representation, _kalman_filter, _kalman_smoother, _simulation_smoother, _cfa_simulation_smoother, _tools
label_desc: Use image node_id 32 for calling a global function with example usage: _compute_smoothed_state_weights(ssm, compute_t, compute_j, compute_prior_weights, scale) and returns: weights,  state_intercept_weights,  prior_weights