Towards Robust Machine Learning under Distribution Shifts: From Causal Guarantees to Robust Federated Learning