for batch in loader:
if your loader returns both inputs and labels, batch will contain tuple (x,y), replace it with
for batch_x, batch_y in loader:
also item() does not give you single tensor. It extracts value of that tensor in Python format (like simple float64). Backprop will not work on item()