Stochastic spectral embedding for Bayesian inverse problems