Oh ok, So i just explained that in words below the code.
output1 = classifier1(feature_extractor)
output2 = classfier2(feature_extractor)

loss1 = criterion(outputs1, labels1)
loss2 = criterion(outputs2, labels2)

total_loss = loss1 + (k * loss2)
total_loss.backward()

This is what I meant above. Is this what you were asking ?