Tensor Network States: Optimizations And Applications In Quantum Many-Body Physics And Machine Learning