Error with detecting cached files when running without Internet connection (related to #10067)
Author: aosokin
Pull request: no

## Environment info
- `transformers` version: 4.5.0.dev0
- Platform: Linux-3.10.0-957.5.1.el7.x86_64-x86_64-with-centos-7.6.1810-Core
- Python version: 3.7.10
- PyTorch version (GPU?): 1.8.0 (True)
- Tensorflow version (GPU?): not installed (NA)
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no

### Who can help
@LysandreJik (related to #10235 and #10067)

## Information
I'm trying to run 
```
from transformers import BertTokenizer
BertTokenizer.from_pretrained("bert-large-uncased-whole-word-masking")
```
from an environment without Internet access. It crashes even though I have all files downloaded and cached. The uncaught exception:
https://github.com/huggingface/transformers/blob/5f1491d3b366d19cc08832d09bcfe007a2643089/src/transformers/file_utils.py#L1347-L1350

When `file_id == 'added_tokens_file'` `file_path` equals https://huggingface.co/bert-large-uncased-whole-word-masking/resolve/main/added_tokens.json which does not exist. (https://github.com/huggingface/transformers/blob/1a3e0c4fe6868b4eb1105dfe601a79d7e5d11a0f/src/transformers/tokenization_utils_base.py#L1653)
This results in line
https://github.com/huggingface/transformers/blob/1a3e0c4fe6868b4eb1105dfe601a79d7e5d11a0f/src/transformers/file_utils.py#L1294 throwing `ConnectTimeout` which is caught in https://github.com/huggingface/transformers/blob/1a3e0c4fe6868b4eb1105dfe601a79d7e5d11a0f/src/transformers/file_utils.py#L1313
and further ignored until another exception in https://github.com/huggingface/transformers/blob/1a3e0c4fe6868b4eb1105dfe601a79d7e5d11a0f/src/transformers/tokenization_utils_base.py#L1672
which is not caught enywhere.

When trying to get the same file with the internet is on the code work differently: line https://github.com/huggingface/transformers/blob/1a3e0c4fe6868b4eb1105dfe601a79d7e5d11a0f/src/transformers/file_utils.py#L1295 throws `requests.exceptions.HTTPError`, which is caught and processed here https://github.com/huggingface/transformers/blob/1a3e0c4fe6868b4eb1105dfe601a79d7e5d11a0f/src/transformers/tokenization_utils_base.py#L1674-L1677
The rest of the code works just fine after `resolved_vocab_files[file_id] = None` 

Using `BertTokenizer.from_pretrained(bert_version, local_files_only=True)` works just fine because of this condition:
https://github.com/huggingface/transformers/blob/1a3e0c4fe6868b4eb1105dfe601a79d7e5d11a0f/src/transformers/tokenization_utils_base.py#L1668-L1672

The current workaround is to use `BertTokenizer.from_pretrained(bert_version, local_files_only=True)` but this does not allow to use same code with and without Internet.

## To reproduce

Steps to reproduce the behavior:

Run 
```
from transformers import BertTokenizer
BertTokenizer.from_pretrained("bert-large-uncased-whole-word-masking")
```
from env without internet but all the required cache files pre-downloaded.

## Expected behavior

Works exactly as 
```
from transformers import BertTokenizer
BertTokenizer.from_pretrained("bert-large-uncased-whole-word-masking", local_files_only=True)
```

Comments:
Related issue: https://github.com/huggingface/transformers/issues/9147, with proposed fix in https://github.com/huggingface/transformers/pull/9807

Why do we need this condition?
https://github.com/huggingface/transformers/blob/1a3e0c4fe6868b4eb1105dfe601a79d7e5d11a0f/src/transformers/tokenization_utils_base.py#L1669-L1672
Was introduced here: https://github.com/huggingface/transformers/commit/863e553f75daeaf09aea9cd521ac3a3b3f09e29f Is it needed in any other scenario?
Would it be better to do `unresolved_files.append(file_id)` unconditionally?

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/master/CONTRIBUTING.md) are likely to be ignored.