Weighted Risk Invariance: Domain Generalization under Invariant Feature Shift