Broken 'export' using transformers.onnx
### Feature request

HuggingFace allows an indirect way to export models that aren't supported by the current version of transformers[onnx], mentioned on huggingface website [here](https://huggingface.co/docs/transformers/serialization#implementing-a-custom-onnx-configuration). 

According to the original website, this method also provides a way to change the heads of the models based on users needs. 
Here is the original code mentioned on the website starting from generating the custom onnx configuration, exporting and validating the exported model.

~~~
from typing import Mapping, OrderedDict
from transformers.onnx import OnnxConfig

class DistilBertOnnxConfig(OnnxConfig):
    @property
    def inputs(self) -> Mapping[str, Mapping[int, str]]:
        return OrderedDict(
            [
                ("input_ids", {0: "batch", 1: "sequence"}),
                ("attention_mask", {0: "batch", 1: "sequence"}),
            ]
        )

from transformers import AutoConfig
model_ckpt = "distilbert-base-uncased"
config = AutoConfig.from_pretrained(model_ckpt)
onnx_config_for_seq_clf = DistilBertOnnxConfig(config, task="sequence-classification")

from pathlib import Path
from transformers.onnx import export
from transformers import AutoTokenizer, AutoModel

onnx_path = Path("C:/Users/Hp/zsc/onnx_deberta/model4.onnx")
base_model = AutoModel.from_pretrained(model_ckpt)
tokenizer = AutoTokenizer.from_pretrained(model_ckpt)
onnx_inputs, onnx_outputs = export(tokenizer, base_model, onnx_config_for_seq_clf, onnx_config_for_seq_clf.default_onnx_opset, onnx_path)

import onnx
onnx_model = onnx.load("C:/Users/Hp/zsc/onnx_deberta/model4.onnx")
onnx.checker.check_model(onnx_model)

from transformers.onnx import validate_model_outputs

validate_model_outputs(
    onnx_config_for_seq_clf, tokenizer, base_model, onnx_path, onnx_outputs, onnx_config_for_seq_clf.atol_for_validation
)
~~~

But for some reason, the **task** doesn't seem to work. If you opt to only export and directly check the output shape of the model, it is always the same, which is the shape of last hidden layer of the model.
The validation is successful only when the model is exported with the default task, i.e. **task=default**.



### Motivation

This is a related issue raised by me prior to this, mentioned [here](https://github.com/huggingface/transformers/issues/16982), which points out the the wrong output shape generated even after specifying the tasks.
This is possibly a problem where the exported model is unable to change the heads of the exported models based on specified tasks.


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.