You can just call loss.backward() on the summed loss.
However, is there a reason you use labels.data for the dice loss instead of directly the tensor?
Probably it won’t make any errors, but the usage of .data is not recommended generally.