Result of slicing in an empty tensor
Can anyone help me to understand why this works:

lens = list(range(170,1,-1))
xs = Variable(torch.randn(169, 200, 1))
packed = torch.nn.utils.rnn.pack_padded_sequence(xs, lens, batch_first=True)


and this does not:

lens = [294, 289, 288, 282, 273, 270, 261, 260, 240, 235, 231, 228, 228, 227, 226, 226, 199, 195, 194, 192, 190, 189, 177, 176, 165, 165, 161, 156, 153, 149, 149, 142, 142, 137, 136, 136, 135, 134, 134, 132, 131, 129, 122, 121, 121, 114, 113, 113, 112, 110, 109, 108, 107, 107, 106, 105, 105, 103, 102, 100, 99, 99, 98, 96, 95, 93, 92, 91, 91, 90, 88, 88, 87, 79, 78, 78, 77, 76, 75, 74, 73, 72, 72, 71, 71, 71, 71, 69, 69, 69, 68, 68, 68, 68, 68, 68, 67, 67, 66, 66, 65, 65, 64, 64, 64, 63, 63, 61, 61, 61, 61, 60, 60, 59, 59, 59, 59, 57, 57, 57, 57, 57, 56, 56, 55, 55, 54, 54, 54, 54, 54, 53, 53, 52, 52, 52, 51, 51, 51, 51, 51, 50, 50, 50, 49, 49, 49, 48, 47, 47, 47, 47, 46, 46, 46, 45, 44, 44, 44, 44, 43, 42, 39, 38, 36, 30, 30, 25, 23]
xs = Variable(torch.randn(169, 200, 1))
packed = torch.nn.utils.rnn.pack_padded_sequence(xs, lens, batch_first=True)


I am getting a "ValueError: result of slicing is an empty tensor"

Answering my own question.

In fact it was answered by SimomW at the Pytorch forum: https://discuss.pytorch.org/t/result-of-slicing-is-an-empty-tensor/13306

It happens because the first len has values all &lt;= 200, but the second has many > 200, which is the maximum seq_len a tensor of shape 169,200,1 can have.
