Solved by albanD in post #6 
              
              
                Hi, 
You can make it into a 3D Tensor of size [batch, 21, 2] and use the same function as above. Since we index with -1 (last dimension), it does not really matter how many there are before. 
Also if the input is always of size 42, you can do .view(-1, 21, 2).