https://medium.com/@monocosmo77/understanding-the-use-of-automatic-differentiation-part1-machine-learning-11fdfd7a404