Incorrect size of input for 1st strided window length in `Perplexity of fixed-length models`
### System Info

- `transformers` version: 4.20.1
- Platform: Linux-5.10.133+-x86_64-with-debian-bullseye-sid
- Python version: 3.7.12
- Huggingface_hub version: 0.8.1
- PyTorch version (GPU?): 1.11.0+cpu (False)
- Tensorflow version (GPU?): 2.6.4 (False)
- Flax version (CPU?/GPU?/TPU?): 0.6.0 (cpu)
- Jax version: 0.3.16
- JaxLib version: 0.3.15

### Who can help?

@sgugger, @stevhliu

### Information

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

### Tasks

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

### Reproduction

1. [The example script for finding the perplexity of fixed length](https://huggingface.co/docs/transformers/perplexity) model using strided windows takes an shorter window size for the 1st set of inputs.  

    For demo, let's us take a subset of test data in the script and print the `begin_loc`, `end_loc`, and `trg_len`. The example script picks a window of [0: 512] for the `input_ids` in 1st pass and then picks [0: 1024] in 2nd pass. The size of `input_ids` in the 1st pass is shorter than expected which should have been [0: 1024] in the 1st pass itself as the model's max length is 1024. 

    This leads to higher overall PPL as the output in the 2nd pass get a smaller context window size. This can be seen in the shared  notebook which prints these stats for the **example script** and the **proposed script** for comparison: https://www.kaggle.com/code/ekagra/perplexity-contrib-small?scriptVersionId=104864785

2. The PPL for GPT2-large when running the example script comes to be 16.44 instead of ~~19.64~~ 16.53. Maybe improvement was made in the tokenizer or in the GPT2 model definition after the example script was written which improves the PPL?

    Sharing notebook for PPL computed on the entire test data for [example script](https://www.kaggle.com/code/ekagra/perplexity-contrib/notebook?scriptVersionId=104846069) and [proposed script](https://www.kaggle.com/code/ekagra/perplexity-contrib?scriptVersionId=104846058).  Both approaches obtain the same PPL of 16.44 as we are taking average over a lot of numbers so the small difference in NLLs in the 1st 2 window size vanishes. The difference however can be seen in the previous notebook which finds PPL over a smaller test data.



If this makes sense then I could raise a PR for this. 

EDIT 1: replaced 19.64 with 16.53 which is the right metric to look for stride size of 512.
Yes, it looks like the PPL is not 19.64 as advertised. Would you like to make a PR with the suggested changes? It all looks good to me.<|||||>Sure @sgugger. On it.