When you run the forward pass, the input values are saved, so that when you run the backward pass, the gradients can be properly calculated. Once the input values have been discarded, the gradients can no longer be computed.
Some operations, such as addition, do not require the inputs to be saved in order to properly calculate the gradients. Try multiplication instead.
f = Variable(torch.Tensor([2,3]), requires_grad=True)
g = f[0] * f[1]
g.backward()
f.grad
g.backward()
f.grad