The model output is an OrderedDict, while tensors are expected in the loss functions.
Use ['out'] to get the class logits:
model = models.segmentation.fcn_resnet50()
output = model(torch.randn(1, 3, 224, 224))
print(output['out'].shape)
> torch.Size([1, 21, 224, 224])

Also note that PyTorch uses “channels-first” tensors, so the class and channel dimensions should be in dim1.