Adding changes to add the Pegasus Onnx Config.
Author: pramodith
Pull request: yes

# What does this PR do?
This pull request makes the required changes to support running the Pegasus model in Onnx runtime, Linked to 
A related PR #18305 was closed because of some git issues I was running into and replaced for this one.

Fixes  https://github.com/huggingface/transformers/issues/16308



## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [X] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [X] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case. Linked to https://github.com/huggingface/transformers/issues/16308
- [X] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [X] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@lewtun 
@ChainYo 

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_18973). All of your documentation changes will be reflected on that endpoint.

@lewtun I tested the export and validated the onnx model using the following code.

```
from transformers.models.pegasus.configuration_pegasus import PegasusOnnxConfig, PegasusConfig
from transformers.models.pegasus import PegasusModel, PegasusTokenizer, PegasusForConditionalGeneration
from transformers.onnx import export, validate_model_outputs
from pathlib import Path

def check_onnx_model(task):
    if task == "default":
        config = PegasusConfig.from_pretrained("google/pegasus-x-base")
        model = PegasusModel.from_pretrained("google/pegasus-x-base")
        tokenizer = PegasusTokenizer.from_pretrained("google/pegasus-x-base")
    elif task == "seq2seq-lm":
        config = PegasusConfig.from_pretrained("google/pegasus-xsum")
        model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum", add_cross_attention=True)
        tokenizer = PegasusTokenizer.from_pretrained("google/pegasus-xsum")
    else:
        config = PegasusConfig.from_pretrained("google/pegasus-xsum")
        model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum")
        tokenizer = PegasusTokenizer.from_pretrained("google/pegasus-xsum")

    onnx_config = PegasusOnnxConfig(config, task=task, use_past=True)
    onnx_path = Path("model.onnx")
    onnx_inputs, onnx_outputs = export(tokenizer, model, onnx_config, onnx_config.default_onnx_opset, onnx_path)
    print(onnx_inputs)
    print(onnx_outputs)
    print(validate_model_outputs(onnx_config,tokenizer,model,onnx_path,onnx_outputs,onnx_config.atol_for_validation))

check_onnx_model("seq2seq-lm")
```

For the case of "seq2seq-lm" I got the following error when I set `use_past = True`. `ValueError: Outputs values doesn't match between reference model and ONNX exported model: Got max absolute difference of: 0.00010585784912109375
`
Is the difference in magnitude of order 1e-4 acceptable?


> For the case of "seq2seq-lm" I got the following error when I set `use_past = True`. `ValueError: Outputs values don't match between the reference model and ONNX exported model: Got max absolute difference of: 0.00010585784912109375 ` Is the difference in magnitude of order 1e-4 acceptable?

Depending on models, 1e-3 is acceptable. I wouldn't go further.



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/main/CONTRIBUTING.md) are likely to be ignored.

> Thanks for adding ONNX support of this architecture @pramodith 🔥 !
> 
> The PR is very clean and I've left a small suggestion to tweak the tolerance level. Once you've included this, could you confirm the slow tests pass with:
> 
> ```
> RUN_SLOW=1 pytest tests/onnx/test_onnx_v2.py -k "pegasus"
> ```

Hey @pramodith just checking if you were able to run the slow tests successfully?

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/main/CONTRIBUTING.md) are likely to be ignored.