RuntimeError: forward() Expected a value of type ‘Tensor’ for argument ‘input_ids’ but instead found type ‘list’ while loading a torchscript model following the documentation 
# ❓ Questions & Help


I followed the documentation  [here](https://huggingface.co/transformers/torchscript.html) to convert transformers model to torchscript,  modified the code for `ALBERT` and then ran them on Google Colab (also my local machine):
**To recurrent:**
 **Step 1**
 ``` from transformers import AlbertModel, AlbertTokenizer, AlbertConfig
import torch
enc = AlbertTokenizer.from_pretrained("albert-xxlarge-v2")
text = "[CLS] Who was Jim Henson ? [SEP] Jim Henson was a puppeteer [SEP]"
tokenized_text = enc.tokenize(text)
masked_index = 8
tokenized_text[masked_index] = '[MASK]'
indexed_tokens = enc.convert_tokens_to_ids(tokenized_text)
segments_ids = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]
tokens_tensor = torch.tensor([indexed_tokens])
segments_tensors = torch.tensor([segments_ids])
dummy_input = [tokens_tensor, segments_tensors]
config = AlbertConfig(torchscript=True)
model = AlbertModel(config)
model.eval()
model = AlbertModel.from_pretrained("albert-xxlarge-v2", torchscript=True)
traced_model = torch.jit.trace(model, [tokens_tensor, segments_tensors])
torch.jit.save(traced_model, "albert-xxlarge-v2.pt") 
```
 I successfully exported the model, but the second code cell threw out a `RuntimeError`:
 **Step 2**
  **Code:**
 ``` 
loaded_model = torch.jit.load("albert-xxlarge-v2.pt")
loaded_model.eval()

all_encoder_layers, pooled_output = loaded_model(dummy_input)
```
  **Error message:** 
```
---------------------------------------------------------------------------

RuntimeError                              Traceback (most recent call last)

<ipython-input-7-2e61b1def246> in <module>()
      2 loaded_model.eval()
      3 
----> 4 all_encoder_layers, pooled_output = loaded_model(dummy_input)

/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
    720             result = self._slow_forward(*input, **kwargs)
    721         else:
--> 722             result = self.forward(*input, **kwargs)
    723         for hook in itertools.chain(
    724                 _global_forward_hooks.values(),

RuntimeError: forward() Expected a value of type 'Tensor' for argument 'input_ids' but instead found type 'list'.
Position: 1
Value: [tensor([[    2,    72,    23,  2170, 27674,    13,    60,     3,     4, 27674,
            23,    21, 10956,  7911,     3]]), tensor([[0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]])]
Declaration: forward(__torch__.transformers.modeling_albert.AlbertModel self, Tensor input_ids, Tensor attention_mask) -> ((Tensor, Tensor))
Cast error details: Unable to cast Python instance to C++ type (compile in debug mode for details) 
``` 
In order to ensure this is't caused by my edit of the code, I also ran all the code there to export `BERT` to TorchScript and **get same error at the same step**. 
 **Software Versions:**

 ``` 
Name: torch 
Version: 1.6.0+cu101  

Name: transformers 
Version: 3.0.2 
```
Is this a problem with the documentation? And how to fix it. Thanks for any advice.



## Details
It shouldn’t  throw out a runtime error and the model should be able to use normally.
Original Link to the Huggingface Forum: [https://discuss.huggingface.co/t/get-runtimeerror-forward-expected-a-value-of-type-tensor-for-argument-input-ids-but-instead-found-type-list-while-loading-torchscript-models-converting-from-transformers/828](https://discuss.huggingface.co/t/get-runtimeerror-forward-expected-a-value-of-type-tensor-for-argument-input-ids-but-instead-found-type-list-while-loading-torchscript-models-converting-from-transformers/828)
Hey @xf05888, 

Thanks for submitting the issue! I can reproduce it. I updated the docs here: #6714 . This should solve your problem I think. The input lists of tensors has to be unpacked before using it.
