Thanks for the update.
It looks generally alright, but you are still using this approach (assuming y is a sample from Dataset2):
x -> resnet -> output -> criterion -> loss1
y -> resnet -> output -> new_logits -> criterion -> loss2

Is that your workflow or would you rather want to switch internally between the last linear layer?