Why is the last grad() below raising an error “RuntimeError: differentiated input is unreachable” ?
from torch import Tensor
from torch.autograd import Variable
from torch.autograd import grad

x = Variable(Tensor([5]), requires_grad = True)
print('x', x)

f = x[0] * x[0] * x[0] - 3 * x[0]
print('f = x^3 - 3x', f)

f1 = grad(f, x, create_graph = True)[0]
print('f1 = 3x^2 - 3', f1)

f2 = grad(f1, x, create_graph = True)[0]
print('f2 = 6x', f2)

f3 = grad(f2, x, create_graph = True)[0]
print('f3 = 6', f3)

f4 = grad(f3, x, create_graph = True)[0]
print('f4 = 0', f4)