tensor.pu_ should work.
Note that you would have to calculate the linear indices for it as shown here:
# Setup
bs, L, V = 2, 3, 4

# Your approach
a = torch.randint(0, V, (bs, L))
b = torch.empty(bs, L).uniform_(0, 1)
c = torch.zeros(bs, V)

for i in range(bs):
    for j in range(L):
        c[i, a[i, j] ] += b[i, j]


# put_ approach
d = torch.zeros(bs, V)
# calculate linear index
lin_index = a + (torch.arange(a.size(0)) * d.size(1)).unsqueeze(1)
d.put_(lin_index, b, accumulate=True)

# Compare
print((c == d).all())
> tensor(True)