Intrinsic Dimension, Persistent Homology and Generalization in Neural Networks