Why do you think it goes against the learnable threshold parameter?
I don’t see in the current code snippet where threshold is created, but in your previous code you were recreating the threshold in each forward pass, so no training was performed on this parameter.