Learning to Extrapolate: A Transductive Approach