When you clamp z in your forward, you should not use the same variable name as the one that was given to the optimizer.
z_clamped = z.clamp(0, 1)
output = model(input + z_clamped)

should work.
Note that the clamp operation will give 0 gradients if z is out of the range, so this might not have a very good behavior while training as as soon as you get out of the range, you will get a 0 gradient. Maybe doing z_clamped = z.sigmoid() will have a better behavior to avoid 0 gradients.