LayoutXLMProcessor: Enforce using "return_overflowing_tokens" with "return_offsets_mapping"
Author: anthony2261
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 -->

Fixes https://github.com/huggingface/transformers/issues/18726

Code to reproduce the error: https://colab.research.google.com/drive/1ETpz8UP42r7HjRg4VUkC7L8ou10qY3bQ?usp=sharing

Specific combination that caused the error: `LayoutXLMProcessor` with `use_fast=False`, `return_overflowing_tokens=True` and `return_offsets_mapping=False`

## Who can review?

@NielsRogge

<!-- 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

 -->


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

Thanks, although it doesn't include the same changes as #17092, could you add those?

> Thanks, although it doesn't include the same changes as #17092, could you add those?

The additional changes in the other PR were already present, I added the missing ones, see the pictures below
This PR:
![image](https://user-images.githubusercontent.com/26882839/186901331-7c5678f5-be9d-4c02-b2fb-183e00b60099.png)

The other PR:
![image](https://user-images.githubusercontent.com/26882839/186901500-800736c0-d3f4-40a4-8c30-e2a0aa34231f.png)


Oh yeah, just realized I added that myself when adding LayoutLMv3. Thanks! I'll add another reviewer before merging

Btw, one issue I have with this is that if we're using the processor with `use_fast=False`, we won't be allowed to process data with `return_overflowing_tokens=True`, because this will force us to set `return_offsets_mapping=True`, and doing that will raise this error:

```
NotImplementedError: return_offset_mapping is not available when using Python tokenizers.
To use this feature, change your tokenizer to one deriving from transformers.PreTrainedTokenizerFast.
More information on available tokenizers at https://github.com/huggingface/transformers/pull/2674
````

I was able to get 1-to-1 token mappings with the non-fast tokenizer but in a very hacky way. If I find a better way, I'll suggest doing that to support `return_overflowing_tokens` with regular tokenizers.

_N.B: This is the same case with LMv2, not sure about LMv3_