Learning to Transform for Generalizable Instance-wise Invariance