`TFAutoModelForSequenceClassification` Onnx export not working
Author: rohitgr7
Pull request: no

### System Info

- `transformers` version: 4.26.0
- Platform: macOS-10.16-x86_64-i386-64bit
- Python version: 3.9.16
- Huggingface_hub version: 0.12.0
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): 2.11.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help?

@gante and @Rocketknight1

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

Run:
```py
from transformers import AutoTokenizer, TFAutoModelForSequenceClassification

# Load tokenizer and TensorFlow weights from the Hub
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
tf_model = TFAutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased")
# Save to disk
tokenizer.save_pretrained("local-tf-checkpoint")
tf_model.save_pretrained("local-tf-checkpoint")
```

Then:
```console
python -m transformers.onnx --model=local-tf-checkpoint onnx/
```

Taken directly from here: https://huggingface.co/docs/transformers/serialization

Looks like some package version issue since I installed it with
```console
pip install transformers[tf,onnx]
```

### Expected behavior

Error
```console
2023-01-30 00:32:22.939113: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Local TensorFlow model found.
Framework not requested. Using tf2onnx to export to ONNX.
2023-01-30 00:32:25.820716: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Some layers from the model checkpoint at local-tf-checkpoint were not used when initializing TFDistilBertModel: ['dropout_19', 'pre_classifier', 'classifier']
- This IS expected if you are initializing TFDistilBertModel from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected if you are initializing TFDistilBertModel from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
All the layers of TFDistilBertModel were initialized from the model checkpoint at local-tf-checkpoint.
If your task is similar to the task the model of the checkpoint was trained on, you can already use TFDistilBertModel for predictions without further training.
WARNING:tensorflow:From /Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/tensorflow/python/autograph/pyct/static_analysis/liveness.py:83: Analyzer.lamba_check (from tensorflow.python.autograph.pyct.static_analysis.liveness) is deprecated and will be removed after 2023-09-23.
Instructions for updating:
Lambda fuctions will be no more assumed to be used in the statement where they are used, or at least in the same block. https://github.com/tensorflow/tensorflow/issues/56089
2023-01-30 00:32:29.729090: I tensorflow/core/grappler/devices.cc:75] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 (Note: TensorFlow was not compiled with CUDA or ROCm support)
2023-01-30 00:32:37.305540: I tensorflow/core/grappler/devices.cc:75] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 (Note: TensorFlow was not compiled with CUDA or ROCm support)
/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/tf2onnx/tf_utils.py:58: FutureWarning: In the future `np.str` will be defined as the corresponding NumPy scalar.  (This may have returned Python scalars in past versions.
  np_data = np_data.astype(np.str).astype(object)
Traceback (most recent call last):
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/tf2onnx/tf_utils.py", line 58, in tf_to_onnx_tensor
    np_data = np_data.astype(np.str).astype(object)
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/transformers/onnx/__main__.py", line 240, in <module>
    main()
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/transformers/onnx/__main__.py", line 232, in main
    export_with_transformers(args)
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/transformers/onnx/__main__.py", line 165, in export_with_transformers
    onnx_inputs, onnx_outputs = export(
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/transformers/onnx/convert.py", line 355, in export
    return export_tensorflow(preprocessor, model, config, opset, output, tokenizer=tokenizer)
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/transformers/onnx/convert.py", line 282, in export_tensorflow
    onnx_model, _ = tf2onnx.convert.from_keras(model, input_signature, opset=opset)
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/tf2onnx/convert.py", line 494, in from_keras
    model_proto, external_tensor_storage = _convert_common(
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/tf2onnx/convert.py", line 164, in _convert_common
    g = process_tf_graph(tf_graph, const_node_values=const_node_values,
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/tf2onnx/tfonnx.py", line 459, in process_tf_graph
    main_g, subgraphs = graphs_from_tf(tf_graph, input_names, output_names, shape_override, const_node_values,
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/tf2onnx/tfonnx.py", line 474, in graphs_from_tf
    ordered_func = resolve_functions(tf_graph)
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/tf2onnx/tf_loader.py", line 760, in resolve_functions
    _, _, _, _, _, functions = tflist_to_onnx(tf_graph, {})
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/tf2onnx/tf_utils.py", line 441, in tflist_to_onnx
    onnx_tensor = tf_to_onnx_tensor(value, name=port_name(node.name))
  File "/Users/goku/miniconda3/envs/tmp/lib/python3.9/site-packages/tf2onnx/tf_utils.py", line 63, in tf_to_onnx_tensor
    raise RuntimeError("Not support type: {}".format(type(np_data.flat[0])))
RuntimeError: Not support type: <class 'bytes'>
```

Should export models without any error

Comments:
Uhmmm I am not knowledgeable about ONNX -- maybe @michaelbenayoun has some ideas? 🤔 

It works on my side. In any case you can try exporting it with optimum:

```python
optimum-cli export onnx --model distilbert-base-uncased onnx/
```

seems like the issue is with `numpy==1.24.1`. Works with `numpy==1.21.6`. Maybe tf2onnx needs to make some updates. Closing this. Thank you both 😃