x = nn.Linear(in, out)(x) is not an inplace operation !
What this does is

create a linear layer
forward x through it and get a new result
assign to this new result the variable name “x”

You would do inplace operation if you use any of pytorch’s method that finish with a trailing underscore (like mul_(), add_(), scatter_() etc) or if you use python’s inplace ops (like +=, /= etc).
For example if you do:
x = torch.rand(1, in, requires_grad=False)
x_new = nn.Linear(in, out)(x) # This is out of place
x += 1 # This is inplace
loss = x_new[0,0]
loss.backward()

So now we modify the input of the Linear inplace so this won’t run.
The ReLU’s backward can be computed both with the input or the output of the function. So we can make inplace relu.