Adaptive variational Bayes: Optimality, computation and applications