Flax t5 Encoder
# What does this PR do?

I notice that there hasn't been a T5EncoderModel for Flax implementation, taking a stab to add it. I didn't find an issue related to this.


## 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).
- [X] Did you write any new necessary tests?

In terms of the test, I wrote it under `pytest tests/models/t5/test_modeling_flax_t5.py` now but seems I'm having trouble running it on my machine so far, although I can import the `FlaxT5EncoderModel` externally and able to use it successfully. I'm working on that, and just want to send the PR first to know if there's more I should add.


## Who can review?  

t5: @patrickvonplaten, @patil-suraj

_The documentation is not available anymore as the PR was closed or merged._<|||||>Hey @crystina-z, 

The PR looks very nice already - think we're close to merging it! Great job so far :-) A FlaxT5Encoder model class is very useful (also to build Diffusion Pipelines like Imagen cc @borisdayma @patil-suraj ) 

Some tests are currently failing because the branch of the PR is not up to date with Transformers' main branch I think. 

Could you try merging the `main` branch into your PR, e.g.:

```
git pull upstream main
```

(if you called the remote `upstream`) <|||||>Let me know if you need help with anything, otherwise I think we can do a final review once the Circle CI is green :-)<|||||>Hi @patrickvonplaten , thanks for comment! Lemme try merge it with main first then.

There are indeed some tests failure I'm not sure about the reason now, like `jax.errors.ConcretizationTypeError` that happens when running `tests/models/t5/test_modeling_flax_t5.py` in my local environment. might need some help later if merging with main not solves it and I can't still find the reason later :P<|||||>Hi @patil-suraj, @patrickvonplaten. I do have two questions regarding to the failing CI tests - 
1. under the `run_tests_tf`, it shows `FAILED tests/models/mobilebert/test_modeling_tf_mobilebert.py::TFMobileBertModelTest::test_resize_token_embeddings
`  [here](https://app.circleci.com/pipelines/github/huggingface/transformers/42780/workflows/5d5e1e0f-0561-4bd2-a3ac-7dbc520a8d73/jobs/492835?invite=true#step-111-4402) without specific failing reason. however, when running the test locally, the test seems passed, tho with some warning cases. Wonder if you have any idea why it's happening?
```
$ pytest tests/models/mobilebert/test_modeling_tf_mobilebert.py::TFMobileBertModelTest::test_resize_token_embeddings                                                                                                                                                    
                                                                            
=============================================================== test session starts ===============================================================      
platform linux -- Python 3.7.13, pytest-7.1.2, pluggy-1.0.0                 rootdir: /scratch/czhang/src/task-mrtydi/mrtydi-ood/transformers, configfile: setup.cfg                                                                  
plugins: mock-3.6.1, typeguard-2.12.1, xdist-2.5.0, hypothesis-6.47.3, dash-2.5.1, timeout-2.1.0, forked-1.4.0                                           
collected 1 item                                                                                                                                         
                                                                            
tests/models/mobilebert/test_modeling_tf_mobilebert.py .                                                                                    [100%]       
                                                                            
================================================================ warnings summary =================================================================      
../../../../../../home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/flatbuffers/compat.py:19                                          
  /home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/flatbuffers/compat.py:19: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses                                                                                     
    import imp                                                                                                                                           
                                                                                                                                                         ../../../../../../home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/keras/utils/image_utils.py:36                                       /home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/keras/utils/image_utils.py:36: DeprecationWarning: NEAREST is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.NEAREST or Dither.NONE instead.                                                                     
    'nearest': pil_image.NEAREST,                                           
                                                                                                                                                         
../../../../../../home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/keras/utils/image_utils.py:37                                     
  /home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/keras/utils/image_utils.py:37: DeprecationWarning: BILINEAR is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BILINEAR instead.                                                                                  
    'bilinear': pil_image.BILINEAR,                                                                                                                      
                                                                                                                                                         
../../../../../../home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/keras/utils/image_utils.py:38                                     
  /home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/keras/utils/image_utils.py:38: DeprecationWarning: BICUBIC is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BICUBIC instead.                                                                                    
    'bicubic': pil_image.BICUBIC,                                                                                                                        
                                                                                                                                                         
../../../../../../home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/keras/utils/image_utils.py:39                                     
  /home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/keras/utils/image_utils.py:39: DeprecationWarning: HAMMING is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.HAMMING instead.                                                                                    
    'hamming': pil_image.HAMMING,                                           
                                                                                                                                                         
../../../../../../home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/keras/utils/image_utils.py:40                                     
  /home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/keras/utils/image_utils.py:40: DeprecationWarning: BOX is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.BOX instead.                                                                                            
    'box': pil_image.BOX,                                                                                                                                                                                                                                                                                          
                                                                            
../../../../../../home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/keras/utils/image_utils.py:41                                     
  /home/czhang/miniconda3/envs/transformers/lib/python3.7/site-packages/keras/utils/image_utils.py:41: DeprecationWarning: LANCZOS is deprecated and will be removed in Pillow 10 (2023-07-01). Use Resampling.LANCZOS instead.                                                                                    
    'lanczos': pil_image.LANCZOS,                                           
                                                                                                                                                         
src/transformers/modeling_tf_utils.py:575                                   
  /scratch/czhang/src/task-mrtydi/mrtydi-ood/transformers/src/transformers/modeling_tf_utils.py:575: DeprecationWarning: invalid escape sequence \d      
    bit_search = re.search("[^\d](\d+)$", dtype.name)                       

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html     
==================================================== 1 passed, 8 warnings in 265.15s (0:04:25) ====================================================  
```

2. under the `check_repository_consistency`, it says public documentation is needed for `FlaxMT5EncoderModel ` and `FlaxT5EncoderModel` [here](https://github.com/huggingface/transformers/runs/7014080791?check_suite_focus=true#step:9:50). While in the [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs#generating-the-documentation), it says we only need to build documentations locally for inspection but not to commit them - 
> You only need to generate the documentation to inspect it locally (if you're planning changes and want to check how they look like before committing for instance). You don't have to commit the built documentation.

I'm a bit confused about how should I deal with the documentation files. and if we'll need to update the documentation, do we just copy the contents under `~/tmp/test-build` to `docs/source/`?

Thanks so much in advance!<|||||>Hey @crystina-z 

> 1. under the run_tests_tf, it shows FAILED

You can ignore the `run_tests_tf` since it's unrelated, rebasing should fix this.

> I'm a bit confused about how should I deal with the documentation files. and if we'll need to update the documentation, do we just copy the contents under ~/tmp/test-build to docs/source/?

This means we need to add `FlaxT5EncoderModel ` and `FlaxMT5EncoderModel` in the [t5.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/t5.mdx) and [mt5.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/mt5.mdx) files respectively.
<|||||>Hi @patrickvonplaten @patil-suraj All tests passed! Also updated all comments above. lmk if there's anything else to change!<|||||>That's great! Reviewing now :-)<|||||>Nice! Thank you all for reviewing as well! Just wonder when could I expect this PR to be merged? @patrickvonplaten @sanchit-gandhi <|||||>Thanks for being patient @crystina-z. Let's wait for @patil-suraj to give his final review then we can merge!<|||||>Awesome sg, thanks!<|||||>Good to merge I think - @patil-suraj feel free to leave comments if you don't like something, but overall it's good to merge :-) 

Great job @crystina-z !!!