Because I was desperate to find an answer and thought that may help.  When I take that out, I get the following:
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-322-16213b95ac4b> in <module>
     12 #     print(loss)
     13     # keep the loss so we can plot it later
---> 14     losses.append(loss.item())
     15 
     16     # Backward and optimize

ValueError: only one element tensors can be converted to Python scalars

So I took the append out and printed the loss but it’s producing all NaNs.