def rmsprop_preconditioner(running_average_factor: float = 0.99, eps: float = 1.0e-7):
    """Create an instance of the adaptive RMSProp preconditioner.

    Parameters
    ----------
        running_average_factor: float
            The decay factor for the squared gradients moving average.
        eps: float
            :math:`\epsilon` constant for numerical stability.

    Returns
    -------
        preconditioner: Preconditioner
            An instance of RMSProp preconditioner.
    """

    def init_fn(params):
        return RMSPropPreconditionerState(
            grad_moment_estimates=jax.tree_util.tree_map(jnp.zeros_like, params)
        )

    def update_preconditioner_fn(gradient, preconditioner_state):
        grad_moment_estimates = jax.tree_util.tree_map(
            lambda e, g: e * running_average_factor
            + g**2 * (1 - running_average_factor),
            preconditioner_state.grad_moment_estimates,
            gradient,
        )
        return RMSPropPreconditionerState(grad_moment_estimates=grad_moment_estimates)

    def multiply_by_m_inv_fn(vec, preconditioner_state):
        return jax.tree_util.tree_map(
            lambda e, v: v / (eps + jnp.sqrt(e)),
            preconditioner_state.grad_moment_estimates,
            vec,
        )

    def multiply_by_m_sqrt_fn(vec, preconditioner_state):
        return jax.tree_util.tree_map(
            lambda e, v: v * jnp.sqrt(eps + jnp.sqrt(e)),
            preconditioner_state.grad_moment_estimates,
            vec,
        )

    def multiply_by_m_sqrt_inv_fn(vec, preconditioner_state):
        return jax.tree_util.tree_map(
            lambda e, v: v / jnp.sqrt(eps + jnp.sqrt(e)),
            preconditioner_state.grad_moment_estimates,
            vec,
        )

    return Preconditioner(
        init=init_fn,
        update_preconditioner=update_preconditioner_fn,
        multiply_by_m_inv=multiply_by_m_inv_fn,
        multiply_by_m_sqrt=multiply_by_m_sqrt_fn,
        multiply_by_m_sqrt_inv=multiply_by_m_sqrt_inv_fn,
    )
Create an instance of the adaptive RMSProp preconditioner.

    Parameters
    ----------
        running_average_factor: float
            The decay factor for the squared gradients moving average.
        eps: float
            :math:`\epsilon` constant for numerical stability.

    Returns
    -------
        preconditioner: Preconditioner
            An instance of RMSProp preconditioner.
    
fortuna/prob_model/posterior/sgmcmc/sgmcmc_preconditioner.py