Accumulate tokens into batches in `PreTrainedTokenizerBase.add_tokens()`
# What does this PR do?

For tokenizers with added tokens that only consist of a small number of special tokens or any number of special tokens with consecutive token IDs, this pull request reduces the time complexity of creating the trie from quadratic to linear. This can easily reduce the time it takes to load a pretrained tokenizer with many added tokens from tens of minutes to seconds.

Fixes #16936.

## Before submitting
- [ ] 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).
- [ ] Did you write any new necessary tests?

## Who can review?

@SaulLu @Narsil

_The documentation is not available anymore as the PR was closed or merged._<|||||>@Narsil Thank you for your review! A better fix would be if we could just accumulate all special and non-special tokens and then call `tokenizer.add_tokens()` once or twice at the end. However, since we need to maintain the order of tokens in the vocab, we need to call `tokenizer.add_tokens()` each time we encounter a token of a different type.

For malicious input, where special and non-special tokens are interleaved, my approach would lead to no speed-up compared to the current code but no slow-down either. For the typical case, where special and non-special tokens form two contiguous regions of identifiers, my approach leads to half the optimum speed and has only small diff against the current code.<|||||>I agree with @SaulLu's review - I'll let @Narsil take a final look and merge if he approves :) 

Thank you for the PR, @Witiko!<|||||>@LysandreJik: Thank you for your review. In https://github.com/huggingface/transformers/issues/16936#issuecomment-1127621789, @Narsil indicated that they don't think they can do a proper review of this PR due to lack of time and familiarity with the code base.<|||||>@Witiko , I think everyone now agrees that this PR is a good step.

I'll let @LysandreJik decide when to merge. 
<|||||>This pull request is now linked from [the witiko/mathberta model in the Model Hub][1], which is adversely affected by #16936. This will allow users to manually apply the fix before it has been merged and released, so that they can use the model.

 [1]: https://huggingface.co/witiko/mathberta#how-to-use