Hello,
you can easily just take the indices you are interested in.
So for example:
a = Variable(torch.randn(20),requires_grad=True)
print (a)
b = a[torch.arange(1,a.size(0),2).long()]
print (b)
b.sum().backward()
print (a.grad)

will give you alternating 0 and 1 because every second index is in the arange.
Best regards
Thomas