Environment Inference for Invariant Learning