Thanks for the answer, I need more clarification unfortunately. Does that mean I need to define them in the CNN architecture and to make an additional output from the network which will serve later on as an input to the custom loss function?
Now I see there are some implementation on how to make trainable weights in multi-task loss, but I am not exactly sure about this specific problem.