Hi,
I don’t see any topk in your code 
Can you give us the stack trace where the error happens?
That should help you pinpoint where the error is. Don’t hesitate to add some print statement in the forward function to check that the sizes are what you expect !