Could you let me know how to deal with the following example case?
Assume that I have an input, where maximum sequence length is 5, minibatch size is 4, and there are 3 possible labels. idxs has effective lengths of sequences in the input.
input = Variable(torch.randn(5,4,3))
idxs = [5,3,3,2]
target = Variable(torch.LongTensor(5,4))
# assume the target labels are assigned corresponding to the input.

Then, In a sequence tagging task, I’d like to get the cross entropy errors for the whole time steps of the first sequence, 3 time steps of the second sequence, and so on considering the values of idxs.
How could I use advanced indexing for addressing this sequence tagging with variable lengthed input sequences?
(I thought masked_select might be used for my purpose but I wonder what would be the most elegant one at this moment before some other features are added.)
Thanks!