Fix bug in slow tokenizer conversion, make it a lot faster
# What does this PR do?

The slow tokenizer conversion currently has a bug where merges with a score of 0 do not get used due to an erroneous check. The check simply tested truthiness, but was actually looking for a `None`. During fixing, I noticed that the code was also slow, so I made it a lot faster.

Fixes #24233

## 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?
- [ ] 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.
- [ ] 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?

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.

@ArthurZucker 

Speed info: the new implementation takes 70 ms, the old one took 123 seconds for the `openlm-research/open_llama_7b` tokenizer mentioned in the issue.<|||||>_The documentation is not available anymore as the PR was closed or merged._<|||||>> Really nice fix and improvement - thanks for working on this ❤️
> 
> Logic all looks good to me. There's a test that's failing, but it's decorated with `@is_flaky` so shouldn't be preventing CI being green here. @ydshieh any insights into what might be happening?

@amyeroberts 

`is_flacky()` won't keep the test green 100%. It just runs the test a few times (default `5`) 😿 . The failing is still expected but less frequently.<|||||>Sorry for the weird error. I forgot to re-run tests after the second commit