If you use PyTorch methods only, you won’t need to write the backward pass yourself in most cases.
To check, if the dice loss was working before, you could call backward on it and look at the gradients in your model.
You could however write your own backward method, e.g. if you have an idea to speed up the computation.