you shouldnt do it that way, you need to change the target/label to float, here is an example:
loss = nn.MSELoss()
input = torch.randn(3, 5, requires_grad=True)
target = torch.randn(3, 5)
output = loss(input, target.float())  # the floating can happen here 
output.backward()