Generalization properties of contrastive world models