ZIN: When and How to Learn Invariance Without Environment Partition?