Computing the Jacobian matrix of a neural network in Python