usage about rnn.pack_padded_sequence
When I use torch.nn.utils.rnn.pack_padded_sequence(), an error occurred.
Here is my code:

import torch
import numpy as np
x = torch.from_numpy(np.array([[1,2,3,4,5,6,0,0],[6,7,8,9,0,0,0,0],[12,83,84,0,0,0,0,0]]))
length =[6,4,3]
print(torch.nn.utils.rnn.pack_padded_sequence(input=x, lengths=length, batch_first=True))


The error is as follows：

Traceback (most recent call last):
  File "/home/pc/PycharmProjects/padded/padded.py", line 112, in &lt;module&gt;
    print(torch.nn.utils.rnn.pack_padded_sequence(input=x, lengths=length, batch_first=True))
  File "/home/pc/anaconda3/lib/python3.6/site-packages/torch/onnx/__init__.py", line 67, in wrapper
    if not might_trace(args):
  File "/home/pc/anaconda3/lib/python3.6/site-packages/torch/onnx/__init__.py", line 141, in might_trace
    first_arg = args[0]
IndexError: tuple index out of range


But when I enter the following code:

import torch
import numpy as np
x = torch.from_numpy(np.array([[1,2,3,4,5,6,0,0],[6,7,8,9,0,0,0,0],[12,83,84,0,0,0,0,0]]))
length =[6,4,3]
print(torch.nn.utils.rnn.pack_padded_sequence(x, lengths=length, batch_first=True))


The result is normal. And I don't know why.

Can you help me solve the problem?

So the reason for this sounds incredibly stupid, but I think it is due to the way how the wrapper/low-level translator function operates on PyTorch functions:

From what I understand about the *args, **kwargs decorators of python (see more here, the problem is that you only have ordered arguments if you pass them without the =.

Meaning, they get stored in a dictionary of keyword/value pairs. Instead, if we look at the relevant part to our error message (this part: File "/home/pc/anaconda3/lib/python3.6/site-packages/torch/onnx/__init__.py"), we can see the following:

first_arg = args[0]


meaning that it wants to address this with an index. Unfortunately, since the keyword is only stored and passed down in the key/value dictionary, we cannot address this with the index, and subsequently the error is thrown.

I have so far not been able to figure out a way around this, because this is very abstract and (potentially) used by many different classes, specifically since it gets passed down through the intermediate layer (in line 67, see stack trace).
