Oh my goodness, your problem is the same as the one I encountered before.Pytorch cannot solve these data processing problems, you just need to give up using pytorch to process data.I used python zip() to parallel output.
PS: If I still misunderstood your question, I think it is all a data processing problem, you have to find a solution elsewhere. As my link said, you need to change the direction of solving the problem yourself.

  
    
    
    DataLoader changes dataset dimension, "CrossEntropyLoss" not work properly 
  
  
    I found the problem: 

I misunderstood the three sentences of Shape in https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html?highlight=crossentropyloss#torch.nn.CrossEntropyLoss. (doc too crude). 
The shape of output in my code is 2. So the following code should be changed like this:

     def __init__(self):
         super(Net, self).__init__()
         self.fc1 = nn.Linear(2,3,True)
         self.fc2 = nn.Linear(3,1,True)

correct: 
         self.linear1 = nn.Linear(2, 3)
  …