why the inplace operation on x doesn’t raise error?

Because in your second example, you change x before the sigmoid. So that is fine.
If you were modifying x after doing the sigmoid, it wouldn;t be a problem either as the sigmoid only requires its output to compute the gradient, not its input.
If you want to see the details, you can see here 25 that result is used to compute the gradients but not self. So you can modify self as much as you want.

Your example code

I think you have a typo as you never use c