quantize_dynamic on T5 model results in `AttributeError: 'function' object has no attribute 'dtype'`
### System Info

- `transformers` version: 4.26.1
- Platform: Linux-5.10.147+-x86_64-with-glibc2.29
- Python version: 3.8.10
- Huggingface_hub version: 0.12.1
- PyTorch version (GPU?): 1.13.1+cu116 (False)
- 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?

@younesbelkada

### Information

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

### Tasks

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

### Reproduction

Paste the following into colab:

```
!pip install transformers sentencepiece accelerate
import torch
from transformers import T5ForConditionalGeneration, T5Tokenizer
model_name = "google/flan-t5-small"
tokenizer = T5Tokenizer.from_pretrained(model_name)
model = T5ForConditionalGeneration.from_pretrained(model_name)
model = torch.quantization.quantize_dynamic(model, {torch.nn.Linear}, dtype=torch.qint8)
input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write a whole Haiku in a single tweet?"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids
output = model.generate(input_ids)
``` 

### Expected behavior

No Error

# Bug
```
AttributeError                            Traceback (most recent call last)
[<ipython-input-3-96b349bbc122>](https://localhost:8080/#) in <module>
      1 input_text = "Answer the following yes/no question by reasoning step-by-step. Can you write a whole Haiku in a single tweet?"
      2 input_ids = tokenizer(input_text, return_tensors="pt").input_ids
----> 3 output = model.generate(input_ids)

10 frames
[/usr/local/lib/python3.8/dist-packages/transformers/models/t5/modeling_t5.py](https://localhost:8080/#) in forward(self, hidden_states)
    314         # See https://github.com/huggingface/transformers/issues/20287
    315         # we also make sure the weights are not in `int8` in case users will force `_keep_in_fp32_modules` to be `None``
--> 316         if hidden_states.dtype != self.wo.weight.dtype and self.wo.weight.dtype != torch.int8:
    317             hidden_states = hidden_states.to(self.wo.weight.dtype)
    318 

AttributeError: 'function' object has no attribute 'dtype'
```

# Fix

When I commented out the lines 316-317 in `transformers/models/t5/modeling_t5.py`, the model runs.

`quantize_dynamic` converts `self.wo.weight` into a bound function which when called, returns the weights. Hence `self.wo.weight` is a function with no attribute `dtype`.

Bug is introduced by #21281
Hello @gerhean 
Thanks for the issue! 
https://github.com/huggingface/transformers/pull/21843 should fix your problem, you can already use the fix by checking out on the branch<|||||>Hi @gerhean 
Now it's on the `main` branch, if you should be able to use it without any issue!