Hi,
I guess you want to compare the gradient values with and without your reverse flag and make sure they are reversed?
Also you want to follow the instructions from https://pytorch.org/docs/stable/notes/extending.html 4 on how to write the custom Function. The one you use is the old version (before 0.3) and is being removed in latest version.