

TITLE
[Flax] Implement FlaxElectraModel, FlaxElectraForMaskedLM, FlaxElectraForPreTraining

COMMENTS
13

REACTIONS
+1: 0
-1: 0
laugh: 0
hooray: 0
heart: 4
rocket: 0
eyes: 0

BODY
# What does this PR do?

1. Implement Flax version of Electra model : `FlaxElectraModel`, `FlaxElectraForMaskedLM`, `FlaxElectraForPreTraining`. Most of the code taken from FlaxBert version with changes in parameters and forward pass.
2. Adjust `convert_to_pytorch` to load weights for Electra
3. Implement `FlaxElectraGeneratorPredictions`, `FlaxElectraDiscriminatorPredictions` for generator and discriminator prediction head.
4. Implement test in `tests/test_modeling_flax_electra.py`

Forward pass works by running
```shell
pytest tests/test_modeling_flax_electra.py
```

Hi @patrickvonplaten  , @mfuntowicz , I've seen your work on FlaxBert, so I'm tagging in case you want to review. Please note that I use `flax setup` instead of decorator `@nn.compact` since the former
- allows to test and inspect submodule
- separate submodule declaration from the forward pass. Forward pass method can be very long if using `@nn.compact`
I'm happy to revert this change to make code style consistent.

Let me know if you have any questions or feedbacks.
Thanks.

## 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/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 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? Yes, test added `tests/test_modeling_flax_electra.py`

## 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.
