It looks like you are dealing with a segmentation task.
So I assume your output would have the shape [batch_size, nb_classes, height, width], is that correct?
If so, you can get the predicted class index using pred = torch.argmax(output, 1).
Using the pred tensor, you should be able to create these color images using a mapping from class index to color code.
If you don’t have the mapping yet, I would suggest to create a dict with some random mapping to your desired colors.