I’m pretty sure I got it working.
EDIT: Just kidding, not quite yet. I’m not actually clearing the gradients here, I’m just accumulating them and printing it at the end.
CODE:

def helper(x):
return 2 * x[0] + 3 * x[1]**2
x = autograd.Variable(torch.FloatTensor([1, 2]), requires_grad=True)
for i in range(3): # number of epochs
print("iteration: " + str(i))
total = autograd.Variable(torch.FloatTensor([0]))
total += helper(x)
total.backward()
x.data -= 0.1 * x.grad.data
print(x.grad[0], x.grad[1])

OUTPUT:
iteration: 0
iteration: 1
iteration: 2
Variable containing:
6
[torch.FloatTensor of size 1]
Variable containing:
11.5200
[torch.FloatTensor of size 1]