How to define loss weights for parts of model?

I need to calculate a loss which is composed by some different parts of a net,but different parts need to have a different weights to constitute a loss value.How should I do for this purpose?
I wonder if the form
is correct???
Can the gradients flow correctly though net in this way?

Thanks for your advice!

yes, from what I see gradients will flow correctly in this case.