ONNX export broken for QA models
Author: vshampor
Pull request: no

# 🐛 Bug

## Information

Model I am using (Bert, XLNet ...): bert-base-uncased

Language I am using the model on (English, Chinese ...): -

The problem arises when using:
* [x] the official example scripts: convert_graph_to_onnx.py
* [x] my own modified scripts: any script attempting to do a regular torch.onnx.export on a `PreTrainedModel`

The tasks I am working on is:
* [x] an official GLUE/SQUaD task: SQuAD
* [ ] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

1. Run:
`src/transformers/convert_graph_to_onnx.py --model bert-base-uncased --framework pt --pipeline question-answering /tmp/test_hf_onnx/test_hf.onnx`

2. Observe in console:
```
Error while converting the model: Only tuples, lists and Variables supported as JIT inputs/outputs. Dictionaries and strings are also accepted but their usage is not recommended. But got unsupported type QuestionAnsweringModelOutput
```

## Expected behavior

Successful export of the model to `/tmp/test_hf_onnx/test_hf.onnx`

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->
     
- `transformers` version: current master ce374ba87767d551f720242d5e64bfa976531079
- Platform: Ubuntu 18.04
- Python version: 3.7
- PyTorch version (GPU?): 1.5.0
- Tensorflow version (GPU?): -
- Using GPU in script?: -
- Using distributed or parallel set-up in script?: -


Comments:
Might I also add that breaking regular PyTorch ONNX export like that with custom model output wrappers is IMO a Really Bad Idea (TM). Your `PreTrainedModel`'s are still `torch.nn.Module`'s, and as such should be exportable using standard `torch.onnx.export` APIs. 

To make matters worse, the proposed `convert_pytorch` API that I discovered in `src/transformers/convert_graph_to_onnx.py` does not work with general argument-forwarding `forward(*args, **kwargs)` wrapper over the specific HF Transformers models. The `convert_pytorch` path's `__code__` shenanigans in their current way fail when exporting the following kinds of models:
```python
class BertWithWrappedForward(BertForQuestionAnswering):
    def forward(*args, **kwargs):
        # pre-forward actions here
        super().forward(*args, **kwargs)
```

The default `torch.onnx.export` path might have worked here, and it would be good to see some kind of support for such models in the `convert_pytorch` API, or at least a fallback scenario.

@mfuntowicz @julien-c @LysandreJik 

Just wanted to add that `convert_graph_to_onnx.py` is also broken for text-generation with GPT2 for me.

Running `python src/transformers/convert_graph_to_onnx.py --pipeline text-generation --model gpt2 --framework pt output/model.onnx` returns
```
Error while converting the model: Only tuples, lists and Variables supported as JIT inputs/outputs. 
Dictionaries and strings are also accepted but their usage is not recommended. But got unsupported type CausalLMOutputWithPast
```

Although the type is different (now `CausalLMOutputWithPast`), this seems to be the same error happening.

To help with resolving the issue, this is the merge that seems to be causing the problems here: [5438](https://github.com/huggingface/transformers/pull/5438)

Also tried running the previous version before this release (`pip install -Iv transformers=3.0.1`), and now my model is properly converted to onnx.

Hi! This was an unseen error that appeared when we made the switch from tuples to namedtuples. The fix was to specify to pipelines to continue using tuples instead of namedtuples!

#6061 should have fixed it, thanks for letting us know!