You can use id(a.storage) to get the underlying storage, and you will find id(a.storage) equals id(b.storage).
And I found these links(1 2 3) useful and I copied the code for checking if two tensors have same base.
import torch
def same_storage(x, y):
return x.storage().data_ptr() == y.storage().data_ptr()
# It works on your test.
t = torch.rand((3,3))
t1 = t[0,:]
t2 = t[:,0]
print(same_storage(t1, t2)) # prints True
x = torch.arange(10)
y = x[1::2]
print(same_storage(x, y)) # prints True
z = y.clone()
print(same_storage(x, z)) # prints False
print(same_storage(y, z)) # prints False