Dear programmer,

I have the following tensors:

"

index = tensor([[1, 1, 1, …, 0, 0, 1],

[0, 0, 2, …, 1, 1, 1],

[1, 1, 0, …, 0, 1, 0],

…,

[0, 1, 2, …, 0, 2, 1],

[2, 0, 1, …, 0, 1, 0],

[2, 1, 1, …, 1, 1, 1]])

"

index.size() = torch.Size([20, 3001])

Also, I have the source tensor which is:

source = torch.zeros(20, 3, 3001)

source.size() = torch.Size([20, 3, 3001])

I would like to use the index tensor and replace the 1 with the source tensor in dim=1.

I know I should use scatter, but I could not able to replace it.

Could you please help me?

Thanks