def sample_filter_smooth(lds_model, key):
    """
    Sample from a linear dynamical system, apply the kalman filter
    (forward pass), and performs smoothing.

    Parameters
    ----------
    lds: LinearDynamicalSystem
        Instance of a linear dynamical system with known parameters

    Returns
    -------
    Dictionary with the following key, values
    * (z_hist) array(timesteps, state_size):
        Simulation of Latent states
    * (x_hist) array(timesteps, observation_size):
        Simulation of observed states
    * (μ_hist) array(timesteps, state_size):
        Filtered means μt
    * (Σ_hist) array(timesteps, state_size, state_size)
        Filtered covariances Σt
    * (μ_cond_hist) array(timesteps, state_size)
        Filtered conditional means μt|t-1
    * (Σ_cond_hist) array(timesteps, state_size, state_size)
        Filtered conditional covariances Σt|t-1
    * (μ_hist_smooth) array(timesteps, state_size):
        Smoothed means μt
    * (Σ_hist_smooth) array(timesteps, state_size, state_size)
        Smoothed covariances Σt
    """
    z_hist, x_hist = lds_model.sample(key)
    μ_hist, Σ_hist, μ_cond_hist, Σ_cond_hist = lds_model.kalman_filter(x_hist)
    μ_hist_smooth, Σ_hist_smooth = lds_model.kalman_smoother(μ_hist, Σ_hist, μ_cond_hist, Σ_cond_hist)

    return {
        "z_hist": z_hist,
        "x_hist": x_hist,
        "μ_hist": μ_hist,
        "Σ_hist": Σ_hist,
        "μ_cond_hist": μ_cond_hist,
        "Σ_cond_hist": Σ_cond_hist,
        "μ_hist_smooth": μ_hist_smooth,
        "Σ_hist_smooth": Σ_hist_smooth
    }