Why is this line in-place operation? How should I make it not in-place?
perturbed[masks] = perturbed[masks] + (gradient * epsilon)[masks]
perturbed[masks] = perturbed[masks].clamp(0, 255)

Error
RuntimeError: a leaf Variable that requires grad has been used in an in-place operation.
PyTorch is complaining that I am modifying a variable that requires gradient in place. However, I could not figure out how I can do it in other ways. Can someone kindly help?