Learning Non-Linear Invariants for Unsupervised Out-of-Distribution Detection