Learning Substructure Invariance for Out-of-Distribution Molecular Representations