Hi,
For code formatting you can use triple backticks ``` before and after. I edited your post, you can take a look by editing again to see what the raw text looks like.

I thought it wasn’t supposed to do that under the no_grad() function. Why does that happen??

It depends on what else you’re doing. If you don’t do any op that saves the value of that Tensor, it is fine to modify it inplace (this is the case here).
If you do require the original value (like in your original post), then the autograd engine will prevent you from doing that.
Note that torch.no_grad is irrelevant here. And the check happens the same way with or without it (even though the computed gradients will be different of course).