Actually I did not say that it is due to torch.no_grad or anything else, I thought you might using something in a wrong way. For the first output you have provided (train data), here is the predicted labels:
tensor([1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0,
        1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1])

And seems ok to me. Although I wanted you to do same experiment with a small batch of test data too to see the logits there.