For some NLS models, generating the gradient and the hessian-vector products take a long time. Because we need either the Jacobian or the Jacobian-vector products, we can use them to obtain the gradient. Performing AD on the gradient and hprod should be deactivated by default.