Is this what you need?
class MyTestDataset():
        def __init__(self, transform_test=None, transform_train=None):
            self.Train = datasets.CIFAR10(root='~/data', train=True,download=False,transform=transform_train)
            self.Test = datasets.CIFAR10(root='~/data', train=False,download=False,transform=transform_test)

        def __getitem__(self, index):    
            x1, y1 = self.Train[index]
            x2, y2 = self.Test[index]
            return x1, x2, y1, y2, index

        def __len__(self):
            return len(self.Test)     
        

dataset = MyTestDataset(transform_test=transform_test, transform_train=transform_train) 
    
loader = torch.utils.data.DataLoader(dataset,batch_size=64,shuffle=True, num_workers=8)

for inputs_train, inputs_test, targets_train, targets_test, idx in loader:

Then the len should be the size of the testing set (10000), since you want the index to be the same.
This is what confuses me since you are not using the last 40000 data in the training dataset…