Correct order of overflowing tokens for LayoutLmV2 tokenizer
Author: Apoorvgarg-creator
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 -->
This PR objective is same as #13179 
Fixes #13148
The issue was resolved for every tokenizer except the LayoutLmV2 tokenizer.

## Before submitting
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section? Yes 👍🏻.
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Yes👍🏻 , #13148
- [x] Did you make sure to update the documentation with your changes? Yes 👍🏻.
- [x] Did you add any necessary tests?
The following test have been added which check the sequence of **`overflowing tokens`**, **`bbox sequence`** and **`input_ids`**.
     - test_maximum_encoding_length_pair_input
     - test_maximum_encoding_length_single_input 
     

## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who 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.

Models:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @LysandreJik

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->
@LysandreJik @sgugger @SaulLu @NielsRogge 

Comments:
Thank you very much for the PR. 

As it seems to me that we didn't see any tests failing for LayoutLMv2 at the time your previous PR was merged, could you confirm that this behaviour is tested for LayoutLMv2 now? As I see that in the PR you did not change any tests, I'd like to make sure we catch the problem with the tests next time :slightly_smiling_face: .

> As I see that in the PR you did not change any tests, I'd like to make sure we catch the problem with the tests next time 🙂 .

@SaulLu, The test `test_maximum_encoding_length_pair_input` and `test_maximum_encoding_length_single_input` were skipped because of the reason `LayoutLMv2 tokenizer requires boxes besides sequences.`
I will make the necessary changes to the file `test_tokenization_layoutlmv2.py` to ensure that we catch the problem next time.
Thank you 

@SaulLu, I have added a function `get_clean_sequences` which gives us list of words along with their ids and boxes, have taken reference from the `test_tokenization_common.py`.
Furthermore, I have modified the `test_maximum_encoding_length_single_input` to ensure the correct order of overflowing order.
Please can you review the changes.
Thank you 

@SaulLu, I have gone through the reviews. I will make the changes.
I didn't commit `test_maximum_encoding_length_pair_input` function because I wanted to see the changes that are required in the `get_clean_sequences` and `test_maximum_encoding_length_single_input`.
Thank you for reviewing and suggesting the changes.

@SaulLu @NielsRogge @LysandreJik, Sorry for the delay in the PR. I am done with most of the work, but I would like to ask for help in Comparing `bbox` sequence for fast tokenizer for `test_maximum_encoding_length_pair_input.` That test isn't working properly. Can you help me from where I should read about this ? 
I am sorry once again for delaying the work.
**_Update: I have resolved the problem I was facing._**

@SaulLu, Working on `test_maximum_encoding_length_pair_input`. Will Commit the changes by end of the day.

@SaulLu @LysandreJik @NielsRogge, could you please review the test added and changes.
Thank you 

@patrickvonplaten @SaulLu @LysandreJik @NielsRogge , Could you please review the PR.
Thank you.

> * Could you add some comments explaining what is done? There is a lot of code so I fear it will become unmaintainable without clear comments explaining what is done.


Sure, Thank you for reviewing.

@SaulLu @LysandreJik, I have been getting these mails, I tried checking the reason for their failing but couldn't understand the issue.
Message : _This request was automatically failed because there were no enabled runners online to process the request for more than 1 days._
Here the [Screenshot](https://user-images.githubusercontent.com/57873504/140864209-d8486bf5-1151-48e0-8e7f-af9692759d30.PNG) 

Thnaks a gain for all your work on this!