Please be clear with your question and provide some code, if you have.
For example, I am not sure what is loss1, loss2 etc. Unless the question is clear, the chance is very less that you will get an answer.