[2301.12067] Learning Optimal Features via Partial Invariance