torch.clamp
https://pytorch.org/docs/stable/generated/torch.clamp.html
Clamps all elements in input into the range
[ min, max ]
.
If min is None, there is no lower bound. Or, if max is None there is no upper bound.