Try to change your BinaryTanh definition to:
# customized module
class BinaryTanh(nn.Module):
    def __init__(self):
        super().__init__()
        self.fn = BinaryTanh_func.apply
        
    def forward(self, input):
        return self.fn(input)