A lot of assignments will be just a shallow copy of the data just for performance reasons.
Instead of copying a huge matrix the data pointer will just be passed so that the assignment is basically free.
You can find more information on numpy’s copying here 2.
Since PyTorch also deals with large data tensors, usually shallow copies will also be used if possible.
a = torch.zeros(2, 2)
b = a
b[0, 0] = 1
print(a)
> tensor([[1., 0.],
          [0., 0.]])
print(b)
> tensor([[1., 0.],
          [0., 0.]])