Maybe I am missing something but for sure your loss class is correct (at least in case of your error) and another point is that you have syntax error in your class, view does not support dtype. So, if you pass anything to dice_loss then you should get error in the first line or even in a simpler scenario, if you pass nothing to dice_loss like:
loss = dice_loss()

you should get missing argument error but you are not getting it because somehow somewhere you are changing dice_loss.