Hi,
From the error message it looks like you are using indexing with wrong indices.
A good way to debug these errors is to simply run the exact same code on CPU, that way you will get a proper stack trace with the exact line that crashed.