Learning When the Concept Shifts: Confounding, Invariance, and Dimension Reduction