It seems that x += 1 will actually modify x in-place. And the problem "one of the variables needed for gradient computation has been modified " did occur when I try to bifurcate the data flow like this
x = self.conv1(input) # main branch
x_p = self.conv1_p(x) # another branch
x += some_layer # main branch

It worked when I change it to:
x = self.conv1(input) # main branch
x_p = self.conv1_p(x) # another branch
x = x + some_layer # main branch

So I thought maybe we should use x = x + everywhere. But then I remember that the official ResNet 1 implementation is actually using the in-place version out += residual and it works.
So I was just wondering when do we have to use x = x + and when should the x += be acceptable.