let us take an example,
if we have an input tensor, which could be classified into 10 classes, and we want to find CrossEntropyLoss.
inp = torch.randn(1, 10)

so, we get input to be something like (this input would be output of our neural network)
tensor([[ 1.4775,  0.7022,  0.7499, -0.7535, -1.4983, -2.3193, -0.6166, -2.3302,
         -0.8847, -0.1915]])

now, we have a target class, which we know is the correct class, let us assume it to be 2.
so, we do,
loss_fn = nn.CrossEntropyLoss()
loss_fn(inp, torch.tensor([2]))

now, this will take softmax of our input, which would give something like this,
sftmx = nn.Softmax(dim=1)
sftmx(inp)
tensor([[0.3918, 0.1804, 0.1892, 0.0421, 0.0200, 0.0088, 0.0483, 0.0087, 0.0369,
         0.0738]])

which means that probability that our input could be one of the 10 classes.
so, here probabillity that our input corresponds to target 2, is 0.1892
so, we will get loss as -log(0.1892), which is
+1.664950622364359

so, this is our CrossEntropyLoss, now as we train, we want our model to change the input we are giving to CrossEntropyLoss, so that this loss reduces.
by default the mean is taken, for example, if we specify,
loss_fn = nn.CrossEntropyLoss(reduction='none')

then it would give you all values for as many predictions you had to make.
so if we had input as
inp = torch.randn(2, 10)

and target as
target = torch.tensor([3, 4])

and then apply loss function to it, then it will give something like,
tensor([3.6951, 2.6064])

which means that loss for first prediction is 3.6951, loss for second prediction is 2.6064.