class_docstr: Results from applying the Kalman smoother and/or filter to a state space
  model.
  
  Parameters
  ----------
  model : Representation
      A Statespace representation
  
  Attributes
  ----------
  nobs : int
      Number of observations.
  k_endog : int
      The dimension of the observation series.
  k_states : int
      The dimension of the unobserved state process.
  k_posdef : int
      The dimension of a guaranteed positive definite covariance matrix
      describing the shocks in the measurement equation.
  dtype : dtype
      Datatype of representation matrices
  prefix : str
      BLAS prefix of representation matrices
  shapes : dictionary of name:tuple
      A dictionary recording the shapes of each of the representation
      matrices as tuples.
  endog : ndarray
      The observation vector.
  design : ndarray
      The design matrix, :math:`Z`.
  obs_intercept : ndarray
      The intercept for the observation equation, :math:`d`.
  obs_cov : ndarray
      The covariance matrix for the observation equation :math:`H`.
  transition : ndarray
      The transition matrix, :math:`T`.
  state_intercept : ndarray
      The intercept for the transition equation, :math:`c`.
  selection : ndarray
      The selection matrix, :math:`R`.
  state_cov : ndarray
      The covariance matrix for the state equation :math:`Q`.
  missing : array of bool
      An array of the same size as `endog`, filled with boolean values that
      are True if the corresponding entry in `endog` is NaN and False
      otherwise.
  nmissing : array of int
      An array of size `nobs`, where the ith entry is the number (between 0
      and k_endog) of NaNs in the ith row of the `endog` array.
  time_invariant : bool
      Whether or not the representation matrices are time-invariant
  initialization : str
      Kalman filter initialization method.
  initial_state : array_like
      The state vector used to initialize the Kalamn filter.
  initial_state_cov : array_like
      The state covariance matrix used to initialize the Kalamn filter.
  filter_method : int
      Bitmask representing the Kalman filtering method
  inversion_method : int
      Bitmask representing the method used to invert the forecast error
      covariance matrix.
  stability_method : int
      Bitmask representing the methods used to promote numerical stability in
      the Kalman filter recursions.
  conserve_memory : int
      Bitmask representing the selected memory conservation method.
  tolerance : float
      The tolerance at which the Kalman filter determines convergence to
      steady-state.
  loglikelihood_burn : int
      The number of initial periods during which the loglikelihood is not
      recorded.
  converged : bool
      Whether or not the Kalman filter converged.
  period_converged : int
      The time period in which the Kalman filter converged.
  filtered_state : ndarray
      The filtered state vector at each time period.
  filtered_state_cov : ndarray
      The filtered state covariance matrix at each time period.
  predicted_state : ndarray
      The predicted state vector at each time period.
  predicted_state_cov : ndarray
      The predicted state covariance matrix at each time period.
  kalman_gain : ndarray
      The Kalman gain at each time period.
  forecasts : ndarray
      The one-step-ahead forecasts of observations at each time period.
  forecasts_error : ndarray
      The forecast errors at each time period.
  forecasts_error_cov : ndarray
      The forecast error covariance matrices at each time period.
  loglikelihood : ndarray
      The loglikelihood values at each time period.
  collapsed_forecasts : ndarray
      If filtering using collapsed observations, stores the one-step-ahead
      forecasts of collapsed observations at each time period.
  collapsed_forecasts_error : ndarray
      If filtering using collapsed observations, stores the one-step-ahead
      forecast errors of collapsed observations at each time period.
  collapsed_forecasts_error_cov : ndarray
      If filtering using collapsed observations, stores the one-step-ahead
      forecast error covariance matrices of collapsed observations at each
      time period.
  standardized_forecast_error : ndarray
      The standardized forecast errors
  smoother_output : int
      Bitmask representing the generated Kalman smoothing output
  scaled_smoothed_estimator : ndarray
      The scaled smoothed estimator at each time period.
  scaled_smoothed_estimator_cov : ndarray
      The scaled smoothed estimator covariance matrices at each time period.
  smoothing_error : ndarray
      The smoothing error covariance matrices at each time period.
  smoothed_state : ndarray
      The smoothed state at each time period.
  smoothed_state_cov : ndarray
      The smoothed state covariance matrices at each time period.
  smoothed_state_autocov : ndarray
      The smoothed state lago-one autocovariance matrices at each time
      period: :math:`Cov(\alpha_{t+1}, \alpha_t)`.
  smoothed_measurement_disturbance : ndarray
      The smoothed measurement at each time period.
  smoothed_state_disturbance : ndarray
      The smoothed state at each time period.
  smoothed_measurement_disturbance_cov : ndarray
      The smoothed measurement disturbance covariance matrices at each time
      period.
  smoothed_state_disturbance_cov : ndarray
      The smoothed state disturbance covariance matrices at each time period.
docstr: Cov(\tilde \alpha_{t}, I) Var(I, I)^{-1}
  
  where I is a vector of forecast errors associated with
  `update_indices`.
  
  Parameters
  ----------
  updates_ix : list
      List of indices `(t, i)`, where `t` denotes a zero-indexed time
      location and `i` denotes a zero-indexed endog variable.
docstr_tok: ["Cov","(","\\tilde","\\alpha_","{","t","}",",","I",")","Var","(","I",",","I",")","^","{","-1","}","where","I","is","a","vector","of","forecast","errors","associated","with","`","update_indices","`",".","Parameters","--","--","--","--","--","updates_ix",":","list","List","of","indices","`","(","t",",","i",")","`",",","where","`","t","`","denotes","a","zero-indexed","time","location","and","`","i","`","denotes","a","zero-indexed","endog","variable","."]
code: def smoothed_state_gain(
      self, updates_ix, t=None, start=None, end=None, extend_kwargs=None
  ):
      r"""
      Cov(\tilde \alpha_{t}, I) Var(I, I)^{-1}
  
      where I is a vector of forecast errors associated with
      `update_indices`.
  
      Parameters
      ----------
      updates_ix : list
          List of indices `(t, i)`, where `t` denotes a zero-indexed time
          location and `i` denotes a zero-indexed endog variable.
      """
      # Handle `t`
      if t is not None and (start is not None or end is not None):
          raise ValueError(
              "Cannot specify both `t` and `start` or `end`."
          )
      if t is not None:
          start = t
          end = t + 1
  
      # Defaults
      if start is None:
          start = self.nobs - 1
      if end is None:
          end = self.nobs
      if extend_kwargs is None:
          extend_kwargs = {}
  
      # Sanity checks
      if start < 0 or end < 0:
          raise ValueError(
              "Negative `t`, `start`, or `end` is not allowed."
          )
      if end <= start:
          raise ValueError("`end` must be after `start`")
  
      # Dimensions
      n_periods = end - start
      n_updates = len(updates_ix)
  
      # Helper to get possibly matrix that is possibly time-varying
      def get_mat(which, t):
          mat = getattr(self, which)
          if mat.shape[-1] > 1:
              if t < self.nobs:
                  out = mat[..., t]
              else:
                  if (
                      which not in extend_kwargs
                      or extend_kwargs[which].shape[-1] <= t - self.nobs
                  ):
                      raise ValueError(
                          f"Model has time-varying {which}"
                          " matrix, so an updated time-varying"
                          " matrix for the extension period is"
                          " required."
                      )
                  out = extend_kwargs[which][..., t - self.nobs]
          else:
              out = mat[..., 0]
          return out
  
      # Helper to get Cov(\tilde \alpha_{t}, I)
      def get_cov_state_revision(t):
          tmp1 = np.zeros((self.k_states, n_updates))
          for i in range(n_updates):
              t_i, k_i = updates_ix[i]
              acov = self.smoothed_state_autocovariance(
                  lag=t - t_i, t=t, extend_kwargs=extend_kwargs
              )
              Z_i = get_mat("design", t_i)
              tmp1[:, i : i + 1] = acov @ Z_i[k_i : k_i + 1].T
          return tmp1
  
      # Compute Cov(\tilde \alpha_{t}, I)
      tmp1 = np.zeros((n_periods, self.k_states, n_updates))
      for s in range(start, end):
          tmp1[s - start] = get_cov_state_revision(s)
  
      # Compute Var(I)
      tmp2 = np.zeros((n_updates, n_updates))
      for i in range(n_updates):
          t_i, k_i = updates_ix[i]
          for j in range(i + 1):
              t_j, k_j = updates_ix[j]
  
              Z_i = get_mat("design", t_i)
              Z_j = get_mat("design", t_j)
  
              acov = self.smoothed_state_autocovariance(
                  lag=t_i - t_j, t=t_i, extend_kwargs=extend_kwargs
              )
              tmp2[i, j] = tmp2[j, i] = np.squeeze(
                  Z_i[k_i : k_i + 1] @ acov @ Z_j[k_j : k_j + 1].T
              )
  
              if t_i == t_j:
                  H = get_mat("obs_cov", t_i)
  
                  if i == j:
                      tmp2[i, j] += H[k_i, k_j]
                  else:
                      tmp2[i, j] += H[k_i, k_j]
                      tmp2[j, i] += H[k_i, k_j]
  
      # Gain
      gain = tmp1 @ np.linalg.inv(tmp2)
  
      if t is not None:
          gain = gain[0]
  
      return gain
  
imports: import numpy
  from types import SimpleNamespace
  from statsmodels.tsa.statespace.representation import OptionWrapper
  from statsmodels.tsa.statespace.kalman_filter import KalmanFilter, FilterResults
  from statsmodels.tsa.statespace.tools import reorder_missing_matrix, reorder_missing_vector, copy_index_matrix
  from statsmodels.tsa.statespace import tools, initialization
label_desc: Use image node_id 6 for calling the SmootherResults obj's underlying member method code with example usage: obj.smoothed_state_gain(updates_ix, t, start, end, extend_kwargs) and returns: gain, out, tmp1