Invariance versus Adversarial Learning in Domain Generalization with Applications to Neuroscience