Solved by elanmart in post #4 
              
              
                I think that should work. 
Also, I just realized that Function should be defined in a different way in the newer versions of pytorch: 

class GradReverse(Function):
    @staticmethod
    def forward(ctx, x):
        return x.view_as(x)

    @staticmethod
    def backward(ctx, grad_output):
        r…