Like tf.clip_by_value, this function returns a tensor of the same type and
shape as input t but with values clamped to be no smaller than to
clip_value_min and no larger than clip_value_max. Unlike
tf.clip_by_value, the gradient is unaffected by this op, i.e.,
[null,null,["Last updated 2023-11-21 UTC."],[],[],null,["# tfp.math.clip_by_value_preserve_gradient\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/math/numeric.py#L64-L96) |\n\nClips values to a specified min and max while leaving gradient unaltered. \n\n tfp.math.clip_by_value_preserve_gradient(\n t, clip_value_min, clip_value_max, name=None\n )\n\nLike [`tf.clip_by_value`](https://www.tensorflow.org/api_docs/python/tf/clip_by_value), this function returns a tensor of the same type and\nshape as input `t` but with values clamped to be no smaller than to\n`clip_value_min` and no larger than `clip_value_max`. Unlike\n[`tf.clip_by_value`](https://www.tensorflow.org/api_docs/python/tf/clip_by_value), the gradient is unaffected by this op, i.e., \n\n tf.gradients(tfp.math.clip_by_value_preserve_gradient(x), x)[0]\n # ==\u003e ones_like(x)\n\n| **Note:** `clip_value_min` needs to be smaller or equal to `clip_value_max` for correct results.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------------|--------------------------------------------------------------------------------------------|\n| `t` | A `Tensor`. |\n| `clip_value_min` | A scalar `Tensor`, or a `Tensor` with the same shape as `t`. The minimum value to clip by. |\n| `clip_value_max` | A scalar `Tensor`, or a `Tensor` with the same shape as `t`. The maximum value to clip by. |\n| `name` | A name for the operation (optional). Default value: `'clip_by_value_preserve_gradient'`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|-------------|---------------------|\n| `clipped_t` | A clipped `Tensor`. |\n\n\u003cbr /\u003e"]]