Perhaps another workaround that I found to be working is this. Turns out that this could be a more memory efficient implementation in my case. Also it would prevent the IO time spent on transferring tensors to CPU.
val = out.max(1)[1]
batch_acc = val.eq_(y).sum().item()