I’m not sure how you would like to scatter the values into T, as I think just indexing V[Idx] might give you the output:
K = 10
V = torch.randn(K)
T = torch.randn(5, 5)
Idx = torch.empty(T.size(), dtype=torch.long).random_(K)

V[Idx]

Would this work for you?