Add type hints for PyTorch BERT.
# What does this PR do?

Add type hints for PyTorch BERT.

Fixes #16059 for PyTorch BERT


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

- text models: @ArthurZucker and @younesbelkada
- type hints: @Rocketknight1

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_23541). All of your documentation changes will be reflected on that endpoint.<|||||>Looks good! The last thing you'll need to do is `pip install transformers[quality]` followed by `make style` in the `transformers` directory. This runs our code formatting tools to make sure everything follows our style guidelines. Once you do that and commit any changes, the tests should pass!

If you run `make style` and you get an error, it may indicate some part of your code that has issues that our code style tools can't correct - if that happens, take a look and try to see what's wrong, and reply here if you can't figure it out!<|||||>It looks like I've got one last error that I cannot figure out, the relevant line of code appears several times in many files without issue otherwise. Could you help with this? <|||||>@Rocketknight1 <|||||>Ah, thanks for the ping! Investigating now<|||||>I've investigated and there's an issue in our copy checking code, specifically the `is_copy_consistent` function. This isn't your fault, and I'll need to file a PR to fix it!

(For internal `transformers` reference): The issue is triggered when a function is copied from with a single-line header, and there is a change that causes its header to now be multi-line (e.g. adding type hints and causing `black` to wrap the line). The `is_copy_consistent` function [builds a replacement function](https://github.com/huggingface/transformers/blob/main/utils/check_copies.py#L238) from the first line of the target function followed by the subsequent lines of the original function, which creates a mangled header if the original header has changed to multi-line but the target has not:

```python
def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None):
        self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
    ) -> List[int]:
```

@sgugger do you want me to make a PR to fix it?<|||||>Lol no, fixing this is really not a priority. The copies can be manually updated.
The only situation this can appear is this one, and it's rare enough that we can deal with it I think.<|||||>Understood! @coledie you might have to do some manual copying to make this work, in that case. Search the repository for the string `# Copied from transformers.models.bert.tokenization_bert_fast.BertTokenizerFast.build_inputs_with_special_tokens`. This will locate functions that are copied from the BERT function and that our repository tools keep in sync with it. If you manually copy your new `build_inputs_with_special_tokens` header over the existing headers in those functions and then rerun `make fixup` or `make fix-copies`, everything should work and the CI should pass.

If you have any issues, let me know and I can make the changes for you!<|||||>@Rocketknight1 Looks like it is working since test failures are unrelated?<|||||>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.