Bayesian Hierarchical Invariant Prediction