Ok, then you still need the batch dimension, which is why you would have to unsqueeze the sample to have dimension [1, 5].
batch_size = 3
a = Variable(torch.LongTensor(batch_size).random_(5))
b = Variable(torch.randn(batch_size, 5))

criterion = nn.CrossEntropyLoss()

for a_, b_ in zip(a, b):
    loss = criterion(b_.unsqueeze(0), a_)
    print(loss)