Support ONNX export for causal LM sequence classifiers
Author: dwyatte
Pull request: yes

# What does this PR do?

Partial fix for https://github.com/huggingface/optimum/issues/1527 in `optimum` when exporting causal LMs with sequence classification support to ONNX

ONNX's argmax operator does not support int64, but that should not be needed here since these are just boolean tensors

## 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?
- [ ] 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.
- [ ] 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).
- [ ] Did you write any new necessary tests?

## Who can review?
@ArthurZucker and @younesbelkada (CC @fxmarty)


Comments:
The failing test might just need a rebase to main otherwise I'll skip it on main and work on a fix 

> The failing test might just need a rebase to main otherwise I'll skip it on main and work on a fix

@ArthurZucker I rebased in https://github.com/huggingface/transformers/pull/27450/commits/807625026226edcd52c747f4c70bc37eddd9bf8e but looks like something is still up with CI. Perhaps different tests get selected based on files changed or between PRs/main

* `torch_tests` from this PR (14627 tests selected): https://app.circleci.com/pipelines/github/huggingface/transformers/78297/workflows/e34f774a-5910-488e-942d-7121d1007bf1/jobs/998415
* `torch_tests` on `main` https://github.com/huggingface/transformers/commit/78f6ed6c70b29c1560780e3869a7ad4c6b3d2710 (7619 tests selected): https://app.circleci.com/pipelines/github/huggingface/transformers/78269/workflows/3e9cb27d-42b0-4b00-bf5f-432eec81c4c0/jobs/997963



@dwyatte Yes, the test fetcher selects a subset of the tests to run based on the files that are touched. In this case, the failing tests (I believe) are unreleated to your PR. The tests involving safetensors have had a patch pushed on main. Could you rebase on main to include these in the test runners?

@amyeroberts I think there are some other problems on `main` still. Here's what's failing in the tests for this PR after the rebases in https://github.com/huggingface/transformers/commit/807625026226edcd52c747f4c70bc37eddd9bf8e and https://github.com/huggingface/transformers/commit/d8ab2c9d02c6d5a658145db87c1abc920fd7cea9

```
FAILED tests/models/switch_transformers/test_modeling_switch_transformers.py::SwitchTransformersModelTest::test_assisted_decoding_sample - RuntimeError: The size of tensor a (3) must match the size of tensor b (4) at non-singleton dimension 3
FAILED tests/models/t5/test_modeling_t5.py::T5ModelTest::test_assisted_decoding_sample - RuntimeError: The size of tensor a (3) must match the size of tensor b (4) at non-singleton dimension 3
FAILED tests/models/speech_to_text/test_modeling_speech_to_text.py::Speech2TextModelTest::test_tf_from_pt_safetensors - AssertionError: False is not true
```

@dwyatte Exactly same unrelated CI failures in #27351 . In addition to the failures related to `safetensors` (you already mentioned above), we also need to resolve the other CI failures caused by `test_assisted_decoding_sample` in `tests_torch`.

Sorry both for the delays, I'll skip these 3 tests as well. cc @gante I'll look into the test_assisted_decoding_sample. 

Hi, @ArthurZucker , regarding the failures caused by `test_assisted_decoding_sample`, there have already been some discussions in #26892 , these failures did not only happen for `switch_transformers` and `t5`, but also happened for `blenderbot` , `pegasus` and `umt5` in my previous CI checks. It seems to be a more general issue that may happen to more than these listed models. Thanks for the help in fixing them!

just merged #27508 which should skip it for all models 

Thanks @ArthurZucker that took care of the remaining failures. This is ready to merge