Actually, If you do not use backward, and just try to use forward feed, nonzero() won’t throw any errors. The issue is related to backward semantics. Currently, I cannot really figure out what is happening. Could you create and issue in pytorch github page 5?
By the way, you can use code format in forum by putting ``` at the start and the end of your code section.