Thanks, your method is very usefully.
Sorry, the last row in my example is wrong, 
tensor([[[-0.7057,  0.2028,  0.5647,  0.6096, -0.3521],
         [ 0.6071, -0.1356,  0.4405, -1.0726, -0.0379]],

        [[ 0.7262,  2.4277, -0.1173,  0.4026,  0.8243],
         [ 1.1217, -0.6436,  1.4286,  0.6216,  0.0021]],

        [[ 0.1190, -0.9509,  0.2875, -0.9116,  0.6941],
         [ 0.3308, -1.5465,  1.9394, -1.4332,  1.3698]]])

Warm Tip:
w[torch.arange(w.size(0)).unsqueeze(1).long(), index] can work.