It looks like your index is missing a row or your array has one additional row (row2 based on the result).
A combination of scatter_add_ and gather would work:
array = torch.tensor([[0., 1, 2, 3, 4, 5, 6],
                      [7, 8, 9, 10, 11, 12, 13],
                      [21, 22, 23, 24, 25, 26, 27]])

index = torch.LongTensor([[0, 0, 1, 1, 1, 2, 2],
                          [0, 1, 1, 2, 2, 2, 2],
                          [0, 0, 0, 1, 1, 1, 2]])

x = torch.zeros(3, 3).scatter_add_(1, index, array)
x.gather(1, index)
> tensor([[  1.,   1.,   9.,   9.,   9.,  11.,  11.],
          [  7.,  17.,  17.,  46.,  46.,  46.,  46.],
          [ 66.,  66.,  66.,  75.,  75.,  75.,  27.]])