ValueError when converting dialogpt to onnx format
## Environment info

- `transformers` version: 4.9.2
- Platform: Darwin-20.5.0-x86_64-i386-64bit
- Python version: 3.7.11
- PyTorch version (GPU?): 1.9.0 (False)
- Tensorflow version (GPU?): 2.2.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help
 @patrickvonplaten, @LysandreJik

## Information

Model I am using ([dialogpt](https://huggingface.co/microsoft/DialoGPT-medium)):
when convert dialogpt to onnx, i meet ValueError:
`ValueError: The type of axis index is expected to be an integer
`

## To reproduce

```
from transformers.convert_graph_to_onnx import convert
from pathlib import Path
convert(framework="pt", model="DialoGPT-medium/", output=Path("onnx/dilogpt.onnx"), opset=11)
```


Gently pinging @michaelbenayoun here<|||||>Gently pinging @lewtun here<|||||>Thanks for the ping! Will take a look :)<|||||>Hey @qiuxia-alone, thank you for raising this issue! The ONNX export API was overhauled in `transformers` v4.9.0 ([link](https://github.com/huggingface/transformers/releases/tag/v4.9.0)), and since then the recommended way to export models is via the `transformers.onnx` package. 

For example, one can export the `DialoGPT-medium` checkpoint as follows:

```python
python -m transformers.onnx --model=microsoft/DialoGPT-medium onnx/ --opset 11
```

Does running the above command solve your issue? You can find more information in the docs of your `transformers` version [here](https://huggingface.co/transformers/v4.9.2/serialization.html#exporting-transformers-models).<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.