Tokens truncated if exceeded 512 tensor shape
### System Info

Hi, 
    Im using Layoutlmv2 pretrained transformer model, if I put "truncation =True" only half of the image were detected remain not
![res](https://user-images.githubusercontent.com/86664855/203488657-64f08e35-7c07-4580-a5f0-3b34675640a2.png)


### Who can help?

@sanchit-gandhi @sgugger 

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

can't modify model weights shape to match the input tensor shape

### Expected behavior

I want to get full predictions, Thanks in advance🙂
Hey @thoufeeq1218! That's a lot of apple crumble! cc'ing in the vision specialist @NielsRogge 😎<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.<|||||>@NielsRogge ping on this issue.<|||||>Hi,

The recommendation here is to apply a "sliding window" approach, which means that, if your sequence of tokens is > 512, you apply a sliding window with a certain stride (like a window that each time takes 512 tokens as input, and then you shift the window 128 tokens - this is called the stride) and then average predictions for tokens which are part of several windows.

You can specify `return_overflowing_tokens` and `stride` arguments in the processor/tokenizer's call method.<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.