I’m not familiar with your use case, but it seems you are currently replacing a computed activation value, which is needed to calculate the gradients, which will yield the error.
Where is new_value coming from and would it be possible to change the computation of f1 so that the value is computed directly?