Hi,
My opinion is similar to @JuanFMontesinos’s. I think you should defining the iterator outside these two for-loops, if you only move it outside the training loop, you will get the same samplings again and again.
What you do should like this:
test_iterator = iter(test_loader)
for epoch in range(args.max_epochs):
    model.train(True)
    ...
    for batch_idx, input in enumerate(train_loader):
        ...
    model.eval()
    test_samples = next(test_iterator)
    ...