Hi,
when using torch.clamp(), the derivative w.r.t. to its input is zero if the input is outside [min, max]. This results in all gradients for previous operations in the graph to become zero due to the chain rule:

In tensorflow, one can use tf.stop_gradient (https://www.tensorflow.org/api_docs/python/tf/stop_gradient 17) to prevent this behavior. Is there something similar for PyTorch?