[T5] Bug correction & Refactor
Author: patrickvonplaten
Pull request: yes

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

**!!!BUG DETECTION!!!** 

While integrating T5v1.1/mT5, a bug in T5 was detected. T5 actually never uses a `relative_position_bias` in the `EncDecSelfAttention` layer. Previously we used a bi-directional `relative_position_bias` in the `EncDecSelfAttention`, which is wrong IMO (see https://github.com/huggingface/transformers/issues/6285#issuecomment-702371111 for reference). An integration test against original T5 model was added to make sure removing `relative_posiiton_bias` is the correct behavior (in case @craffel reads this - maybe you could confirm :-)). 

Luckily, the bug did not significantly influence the results as can be seen by the very minor changes in the slow tests. This  is also why it wasn't noticed earlier. => Oo all pre-trained & fine-tuned T5Models still work!

In addition this PR:
- Refactor: clean the code, and remove unnecessarily complicated code
- Remove `n_positions` / `max_position_embeddings` from the config, since T5 is not limited by a  fixed learned position embedding matrix, see: https://github.com/huggingface/transformers/issues/8047

Fixes #8047

Also cc @agemagician for information (I highly doubt though that this will fix the problem we have in your case)

## Before submitting
- [x] 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/master/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 the 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/master/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/master/docs#writing-source-documentation).
- [x] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors which may be interested in your PR.

<!-- Your PR 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.

 albert, bert, XLM: @LysandreJik
 GPT2: @LysandreJik, @patrickvonplaten
 tokenizers: @mfuntowicz
 Trainer: @sgugger
 Benchmarks: @patrickvonplaten
 Model Cards: @julien-c
 examples/distillation: @VictorSanh
 nlp datasets: [different repo](https://github.com/huggingface/nlp)
 rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)
 Text Generation: @patrickvonplaten, @TevenLeScao
 Blenderbot, Bart, Marian, Pegasus: @patrickvonplaten
 T5: @patrickvonplaten
 Rag: @patrickvonplaten, @lhoestq
 EncoderDecoder: @patrickvonplaten
 Longformer, Reformer: @patrickvonplaten
 TransfoXL, XLNet: @TevenLeScao, @patrickvonplaten
 examples/seq2seq: @patil-suraj
 examples/bert-loses-patience: @JetRunner
 tensorflow: @jplu
 examples/token-classification: @stefan-it
 documentation: @sgugger
 FSTM: @stas00
 -->


Comments:
I have tested both "refactor_t5" and "major_t5_refactor" branches using "T5ForConditionalGeneration".

I didn't re-convert the Tensorflow to Pytorch, since you already told me the conversion process is not the problem.

Doesn't seem it solved our issue yet, but it gives different rubbish output. Maybe, it is a good step into the right direction.

Thanks Patrick.



Hi @patrickvonplaten, does this PR effects the checkpoint one gets when calling  ```AutoModel.from_pretrained("t5-3b")```?

 I am investigating why my results with transformers 3.3.1 and T5 changed and encountered this, according to the date seems like it was merged in version 3.5.0. (edit: I see now it was merged in 4.0.0 https://github.com/huggingface/transformers/releases/tag/v4.0.0)

I wonder if this changes the T5 weights/checkpoint I get with my version?