Which criterion are you using and what ranges are expected in mask and depth?
Also, you shouldn’t call item() on the losses, if you plan to call train_loss.backward().
PS: Could you format the code by wrapping it into three backticks ``` as it’ll be easier for debugging?