Thanks for your reply, I have removed the comments before @staticmethod (#) :
class BinActive(torch.autograd.Function):
    '''
    Binarize the input activations and calculate the mean across channel dimension.
    '''   
    @staticmethod
    def forward(self, input):
        self.save_for_backward(input)
        size = input.size()
        mean = torch.mean(input.abs(), 1, keepdim=True)
        input = input.sign()
        return input, mean
    @staticmethod
    def backward(self, grad_output, grad_output_mean):
        input, = self.saved_tensors
        grad_input = grad_output.clone()
        #grad_input[input.ge(1)] = 0
        #grad_input[input.le(-1)] = 0
        return grad_input

however, when I try to train the network I have this problem:
---> 21         x, mean = BinActive()(x)
     22 
     23         x = self.conv(x)

TypeError: forward() missing 1 required positional argument: 'input'