The code I shared actually runs on the CPU by default. This section provides the code for running it on a GPU.
Here 1 is the code. It would be great if you could let me know the errors I’ve made. FYI, I ran this code on my system and not in Colab. I just uploaded the notebook over there for sharing it.