Find the max in sepcific dim and replace by 1 and other 0

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

Could you describe this approach with a small example? I’m currently unsure if you want to replace values in source where the index tensor has values of 1 or if the index tensor should be used as a plain index to assign new values to source.