[DocTest] Doctest for Electra Pytorch
Author: bhadreshpsavani
Pull request: yes

# What does this PR do?
Adds Doctest fo Electra Pytorch

Issue: #16292

## 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/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [x] 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.
- [x] 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?


## Who can review?
@ydshieh 


Comments:
_The documentation is not available anymore as the PR was closed or merged._

Hi @ydshieh,
The issue we discussed in Issue:16292
For PyTorch its running fine,
only In case of TensorFlow its giving issue,
I am sharing [notebook](https://colab.research.google.com/drive/1buzYMKgm3b8kfTcyVvnToJCFLqdnZDxM?usp=sharing) for reproducing the issue.

> Hi @ydshieh, The issue we discussed in Issue:16292 For PyTorch its running fine, only In case of TensorFlow its giving issue, I am sharing [notebook](https://colab.research.google.com/drive/1buzYMKgm3b8kfTcyVvnToJCFLqdnZDxM?usp=sharing) for reproducing the issue.

Hi, I am not able to open it. Could you make it public?

Hi @ydshieh,
I have updated the link

@bhadreshpsavani Thanks. It looks like PyTorch somehow made it to run, despite the indices are wrong and out of range.
It gave strange loss value though.

I opened a PR to address this situation

https://github.com/huggingface/transformers/pull/16648. Let's wait it being reviewed and merged to proceed.

Thank you for your patience!

Hi @ydshieh,

When I used this code and rebase at the end I messed up the commits, is there any way to remove earlier commits from this PR?

I think I need to close this PR and create a separate one

Hi, @bhadreshpsavani 

I think close this PR and create a new one is the easiest way (considering the change in your PR is not so large).
Thank you for the effort.

BTW, I think you used `git merge` rather than `git rebase`. In general, `git rebase` could avoid this situation :-).

(There might be other ways of doing things, but I am not a real git expert)

I followed this,
```
git checkout main  # or `master`, depends on your local clone
git fetch upstream
git pull upstream main  # Hugging Face `transformers` renamed the default branch to `main` recently
git checkout your_working_branch_for_this_sprint
git rebase main  # or `master`
```
In the end, there was a merge conflict so i use something like `git rebase --continue` after solving the conflict and sync the changes. It got messed up!

I need to be more careful!


> I followed this,
> 
> ```
> git checkout main  # or `master`, depends on your local clone
> git fetch upstream
> git pull upstream main  # Hugging Face `transformers` renamed the default branch to `main` recently
> git checkout your_working_branch_for_this_sprint
> git rebase main  # or `master`
> ```
> 
> In the end, there was a merge conflict so i use something like `git rebase --continue` after solving the conflict and sync the changes. It got messed up!
> 
> I need to be more careful!

OK, conflict is not easy thing.