novice7:

index is tensor([0, 0, 1, 2, 3])


You are giving
input = torch.Tensor([2, 9, 7, 8, 4])
input 
# tensor([2., 9., 7., 8., 4.])

indexes = torch.Tensor([0, 0, 1, 2, 3])
indexes
# tensor([0., 0., 1., 2., 3.])

desired = torch.Tensor([[2, 9], [7, 0], [8, 0], [4, 0]])
desired
# tensor([[2., 9.],
#         [7., 0.],
#         [8., 0.],
#         [4., 0.]])

What does it mean to have 0 inside the index tensor? Here I see you having the value 0 twice. If you are selecting elements from the given tensor, input = torch.Tensor([2., 9., 7., 8., 4.]) I would expect to see five elements been selected; and the first element, input[0] which is 2, to be repeated twice. But I don’t see that on the desired output you gave. So, I am not following what is this operation you want.
Can you describe what index does to the input tensor? How come the maximum value in index is 3, but the last element of the input tensor, which is input[4] with value 4 is present on the desired output tensor?