Solved by albanD in post #4 
              
              
                If you add extra dimensions, you can simply expand B in these dimensions: 
A.gather(1, B.unsqueeze(-1).expand(batch, data_len, data_dim)