class test(nn.Module):
    def forward(self, x):
        a = torch.LongTensor(np.arange(x.size()[1]))
        return x.index_select(1, a)

here a needs to be a Variable, not a Tensor.
a = Variable(torch.LongTensor(np.arange(x.size()[1])))