Is there a way to create a callable gradient function? Take for example the following tutorial from Autograd:
import autograd.numpy as np 
from autograd import grad 

def tanh(x):              
     y = np.exp(-x)
     return (1.0 - y) / (1.0 + y)

grad_tanh = grad(tanh)
grad_tanh(1.0)

It is not clear how one can do this using the grad function in PyTorch.
Thanks!