For selecting your data:
x = Variable(torch.Tensor([[0,1,2,3,4,5,6,7,8,9],[10,11,12,13,14,15,16,17,18,19]])).t()
i = Variable(torch.LongTensor([[0,1],[3,4],[7,9]]))
x[i]  # should give you what you want

For summing your data:
x[i].sum(1)