Getting error on Google Colab : invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

Hi All,
Can someone please help with the below error.
I have no idea what went wrong and here is my error and code link from my Github please help in fixing the error.

As the error message suggests, you should use tensor.item() instead of tensor[0].
Also, don’t use the .data attribute, as it might yield unwanted side effects.