Yes, you are correct.
You would have to use something like this as your target (for 2 output units):
batch_size = 10
nb_classes = 2
target = torch.LongTensor(batch_size).random_(nb_classes)

Yes you are also right about the sizes. Sometimes to need to unsqueeze the target in case the batch dimension is missing.