Ok, so each channel corresponds to a class in your target images.
Now we have to get the class and just save the indices.
I created a small example where target is your target image and labels is the tensor we are using for the criterion:
target = torch.randn(1, 10, 24, 24)
target = F.softmax(target, dim=1) > 0.5
# target has now a 1 in channel c if the pixel location belongs
# to that class (like your target images)

labels = torch.argmax(target, dim=1)
# labels has now indices for the corresponding class