This should work:
# Setup
ind = torch.tensor([0, 2, 1, 3])
A = torch.zeros(4, 4)
r = torch.randn(4)

# Your code
for i in range(4):
    A[i, ind[i]] = r[i]

# Alternative
B = torch.zeros(4, 4)
B[torch.arange(4), ind] = r
print((B == A).all())
> tensor(True)