This error is raised, if the shapes of the input tensors are unexpected, so make sure the model output has the shape [batch_size, nb_classes, *], while the target has the shape [batch_size, *] containing the class indicex in the range [0, nb_classes-1].
Here is a small code snippet showing the error:
batch_size, nb_classes = 2, 10
x = torch.randn(batch_size, nb_classes)
y = torch.randint(0, nb_classes, (batch_size,))
criterion = nn.CrossEntropyLoss()
loss = criterion(x, y)

y = torch.randint(0, nb_classes, (batch_size, nb_classes))
loss = criterion(x, y)
> RuntimeError: 1D target tensor expected, multi-target not supported