Ok, here what I think you could try. Basically, your model will learn to not predict the -10 values and hopefully learn to ignore them from the input. It may not be exactly as you want, but it is the only way I can see it done without modifying the size of the input. It is inspired by what is done in stereo estimation, as you can see here code.
# consider only the elements different of -10
mask = (target != -10)
mask.detach_()
...
loss = F.mse_loss(input[mask], target[mask])
loss.backward()
...