You need to implement the backward function yourself, if you need non-PyTorch operations (e.g. using numpy) or if you would like to speed up the backward pass and think you might have a performant backward implementation for pure PyTorch operations.
Basically, if you just use PyTorch operations, you don’t need to define backward as Autograd is able to track all operations and create the backward pass.
Your method looks fine! If you want to check for gradients, just call dice_coeff.backward() and check some layers for gradients. Something like this should work:
...
dice_coeff = dice_loss(pred, target)
dice_coeff.backward()
print(model.fc.weight.grad)

If that gives you valid gradients, you could check the range of both losses and scale one if necessary.