Group-robust Sample Reweighting for Subpopulation Shifts via Influence Functions