'tuple' object doesn't have attribute `as_list`
## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

```
- `transformers` version: 4.12.3
- Platform: Linux-5.10.0-9-amd64-x86_64-with-glibc2.2.5
- Python version: 3.8.12
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): 2.6.2 (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
<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- ALBERT, BERT, XLM, DeBERTa, DeBERTa-v2, ELECTRA, MobileBert, SqueezeBert: @LysandreJik
- encoder-decoder models (For example, BlenderBot, BART, Marian, Pegasus, T5, ByT5): @patrickvonplaten, @patil-suraj
- Longformer, Reformer, TransfoXL, XLNet, FNet: @patrickvonplaten
- FSMT: @stas00
- Funnel: @sgugger
- GPT-2, GPT: @patrickvonplaten, @LysandreJik
- RAG, DPR: @patrickvonplaten, @lhoestq
- TensorFlow: @Rocketknight1
- JAX/Flax: @patil-suraj @patrickvonplaten 
- TAPAS, LayoutLM, LayoutLMv2, LUKE, ViT, BEiT, DEiT, DETR, CANINE: @NielsRogge
- GPT-Neo, GPT-J, CLIP: @patil-suraj
- Wav2Vec2, HuBERT, SpeechEncoderDecoder: @patrickvonplaten, @anton-l

If the model isn't in the list, ping @LysandreJik who will redirect you to the correct contributor.

Library:

- Benchmarks: @patrickvonplaten
- Deepspeed: @stas00
- Ray/raytune: @richardliaw, @amogkam
- Text generation: @patrickvonplaten
- Tokenizers: @LysandreJik
- Trainer: @sgugger
- Pipelines: @Narsil
- Speech: @patrickvonplaten, @anton-l
- Vision: @NielsRogge, @sgugger

Documentation: @sgugger

Model hub:

- for issues with a model, report at https://discuss.huggingface.co/ and tag the model's creator.

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj

For research projetcs, please ping the contributor directly. For example, on the following projects:

- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

## Information

I'm sorry for not being able to give more information about this, since I don't directly works with the model. I believe the model is [bert-base-multilingual-cased](https://huggingface.co/bert-base-multilingual-cased). I'm trying to create a chat bot with Rasa.

## To reproduce

Steps to reproduce the behavior: Run the chat bot, either use `rasa shell` or `rasa run --enable-api` and `curl` to chat with the bot.

Error log:
```
2021-11-09 08:08:34 ERROR    rasa.core.channels.rest  - An exception occured while handling user message 'hello'.
Traceback (most recent call last):
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/core/channels/rest.py", line 120, in receive
    await on_new_message(
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/core/channels/channel.py", line 89, in handler
    await app.agent.handle_message(message)
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/core/agent.py", line 577, in handle_message
    return await processor.handle_message(message)
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/core/processor.py", line 96, in handle_message
    tracker = await self.log_message(message, should_save_tracker=False)
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/core/processor.py", line 327, in log_message
    await self._handle_message_with_tracker(message, tracker)
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/core/processor.py", line 594, in _handle_message_with_tracker
    parse_data = await self.parse_message(message, tracker)
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/core/processor.py", line 572, in parse_message
    parse_data = await self.interpreter.parse(
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/core/interpreter.py", line 145, in parse
    result = self.interpreter.parse(text)
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/nlu/model.py", line 470, in parse
    component.process(message, **self.context)
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/nlu/utils/hugging_face/hf_transformers.py", line 749, in process
    self._get_docs_for_batch(
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/nlu/utils/hugging_face/hf_transformers.py", line 678, in _get_docs_for_batch
    ) = self._get_model_features_for_batch(
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/nlu/utils/hugging_face/hf_transformers.py", line 609, in _get_model_features_for_batch
    sequence_hidden_states = self._compute_batch_sequence_features(
  File "/home/grooo/.local/lib/python3.8/site-packages/rasa/nlu/utils/hugging_face/hf_transformers.py", line 460, in _compute_batch_sequence_features
    model_outputs = self.model(
  File "/home/grooo/.local/lib/python3.8/site-packages/keras/engine/base_layer.py", line 1037, in __call__
    outputs = call_fn(inputs, *args, **kwargs)
  File "/home/grooo/.local/lib/python3.8/site-packages/transformers/models/bert/modeling_tf_bert.py", line 1129, in call
    outputs = self.bert(
  File "/home/grooo/.local/lib/python3.8/site-packages/keras/engine/base_layer.py", line 1037, in __call__
    outputs = call_fn(inputs, *args, **kwargs)
  File "/home/grooo/.local/lib/python3.8/site-packages/transformers/models/bert/modeling_tf_bert.py", line 803, in call
    attention_mask_shape = shape_list(inputs["attention_mask"])
  File "/home/grooo/.local/lib/python3.8/site-packages/transformers/modeling_tf_utils.py", line 1831, in shape_list
    static = tensor.shape.as_list()
AttributeError: 'tuple' object has no attribute 'as_list'
```

Line 1831 of `transformers/modeling_tf_utils.py`:
```python
static = tensor.shape.as_list()
```

After printing out stuff in `transformers/modeling_tf_utils.py`, I found out that sometime `tensor` is a numpy array, therefore `tensor.shape` is a tuple and indeed doesn't have `as_list`.

Proposed fix:
```python
    static = tensor.shape
    if type(static) == tuple:
        static = list(static)
    else:
        static = static.as_list()
```


<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior
No error.
<!-- A clear and concise description of what you would expect to happen. -->

I also encountered this error when upgrading Transformers from version 3.5.1 --> 4.12.2.
Can confirm @ndgnuh's proposed fix works!

Can this fix be incorporated into the bug fixes?<|||||>Nice catch, do you want to open a PR with the fix?<|||||>Sorry but I have a potato computer and I'm too lazy for the full PR procedure :smile: <|||||>cc @Rocketknight1 <|||||>This looks like the same issue as #14404, it definitely needs a fix<|||||>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.