You can index the Dataset directly and check for equal values:
x = torch.randn(42, 2048)
y = torch.randn(42, 1)

dataset = TensorDataset(x, y)

for idx in range(x.size(0)):
    data, target = dataset[idx]
    assert (data==x[idx]).all(), "data shuffled"
    assert (target==y[idx]).all(), "target shuffled"




 chaslie:

X_Train is the 42000x2048 input data and y_train is the labels 1x42000 array numbering from 1 t0 42000


That would raise an exception, since the number of samples is different for X_Train and y_train (42000 vs. 1). Could you check it again and post the code how you are creating the [16, 1, 2048]-shaped tensor?