Solved by bsridatta in post #2 
              
              
                change torch.LongTensor(index) → torch.LongTensor([index]) 
the first creates a tensor of size index, the second creates a tensor with value index.