Solved by KFrank in post #2 
              
              
                Hi Iaroslav! 

Yes, it is perfectly reasonable to add the two losses together, and 
there is no need to write a custom loss function. 
So, something like: 
loss_task_1 = torch.nn.CrossEntropyLoss() (pred_head_1, target_task_1)
loss_task_2 = torch.nn.CrossEntropyLoss() (pred_head_2, target_task_2)
to…