Thanks a lot! It worked but I didn’t get the underlying problem. What did changing it to .item() do?
And regarding the epoch, I wanted the epoch to start from 1 instead of the usual  0. So thus the epoch += 1