This code should work:
A = torch.tensor([[1,2,3,4,5,6,7,8],
                  [5,6,7,8,9,10,11,12],
                  [3,5,6,7,8,8,10,11]])

idx_list = torch.tensor([3,1,5])

values = A[torch.arange(A.size(0)), idx_list]
idx = A < values[:, None]
A[idx] = values[:, None].expand(values.size(0), A.size(1))[idx]