This is because of the loss function.
cross entropy doesnt accept the one hot encoding of the target variables.
Place the below code before loss =loss1+loss2
labels1,labels2 = labels[:, 0], labels[:, 1] 
targetnp=labels1.cpu().numpy()
targetnp1 = labels2.cpu().numpy()
l1=np.where(targetnp>0)[1]
l2=np.where(targetnp1>0)[1]
new_targets=torch.LongTensor(idxs)
new_targets1=torch.LongTensor(idxs1)
new_targets = new_targets.to(device)
new_targets1 = new_targets1.to(device)          
loss1 = loss_fn(out1, new_targets)
loss2 = loss_fn(out2,new_targets1)