Literally follow the instructions. You write loss.data[0] and need loss.item() instead. It’s been a long while since loss.data[0] was a good thing to write, see the 0.4 migration guide 169 on how to update ancient ( ) code.
Best regards
Thomas