@albanD I came across a behavior that I don’t really understand, whereby a cloned variable ends up having no gradient. Could you clarify what is going on here? This is the example:
import torch
from torch.autograd import Variable

def basic_fun(x):
    return 3*(x*x)

def get_grad(x):
    A = basic_fun(x)
    A.backward()
    return x.grad

x = Variable(torch.FloatTensor([1]), requires_grad=True)
xx = x.clone()

# this works fine 
print(get_grad(x))

# this doesn't
print(get_grad(xx))