This wouldn’t work for a multi-class segmentation with nn.CrossEntropyLoss or nn.NLLLoss, since the target has to contain a class index.
With three classes the class indices would be [0, 1, 2] and that for each pixel one of these classes would be active.
If you consider your use case a multi-label segmentation, you could use nn.BCEWithLogitsLoss, which would allow you to define zero, one, or more active classes for each pixel.
This approach would work for 3 explicit channels, as no active class could be considered the “background class”. However, since each pixel could also have all classes set to active, this would be a multi-label segmentation.