Simulation-based inference of Bayesian hierarchical models while checking for model misspecification