It depends on what #stuff here is!
If it uses only functions that autograd can understand (i.e. functions that have implemented .backward()) then yes, it should be working. Try for example with
>>> x = torch.autograd.Variable(torch.Tensor(1), requires_grad=True)
>>> x
Variable containing:
 2.8327
[torch.FloatTensor of size 1]
>>> f = lambda x: x*3
>>> y = f(x)
>>> y
Variable containing:
 8.4982
[torch.FloatTensor of size 1]
>>> y.backward()
>>> y.grad #displays nothing since it is None
>>> x.grad
Variable containing:
 3
[torch.FloatTensor of size 1]

In this case autograd can compute the .backward() method on y because it understands that * means multiplication and know how to deal with it; same thing for + and other common operators. If you use other functions that autograd doesn’t know about then it won’t work