Unable to instantiate tokenizer with `TRANSFORMERS_OFFLINE=1`
Just some context, we use `TRANSFORMERS_OFFLINE=1` in the NeMo CI to ensure we load from the local cache. With the latest transformers version we noticed this bug in our CI!

### System Info

- `transformers` version: 4.22.1
- Platform: Linux-5.15.0-41-generic-x86_64-with-glibc2.31
- Python version: 3.9.12
- Huggingface_hub version: 0.9.1
- PyTorch version (GPU?): 1.12.1+cu113 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: no
- Using distributed or parallel set-up in script?: no

### Who can help?

@SaulLu 


### Information

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

### Tasks

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

### Reproduction

Create this script `reprod.py`:

```python
from transformers import AutoTokenizer

AutoTokenizer.from_pretrained(pretrained_model_name_or_path='gpt2')
```

run:

```
python reprod.py
TRANSFORMERS_OFFLINE=1 python reprod.py
```

First one runs successfully, second one fails:

```
Traceback (most recent call last):
  File "/home/snarenthiran/NeMo/reprod.py", line 3, in <module>
    AutoTokenizer.from_pretrained(pretrained_model_name_or_path='gpt2')
  File "/home/snarenthiran/anaconda3/lib/python3.9/site-packages/transformers/models/auto/tokenization_auto.py", line 549, in from_pretrained
    tokenizer_config = get_tokenizer_config(pretrained_model_name_or_path, **kwargs)
  File "/home/snarenthiran/anaconda3/lib/python3.9/site-packages/transformers/models/auto/tokenization_auto.py", line 418, in get_tokenizer_config
    commit_hash = extract_commit_hash(resolved_config_file, commit_hash)
  File "/home/snarenthiran/anaconda3/lib/python3.9/site-packages/transformers/utils/hub.py", line 225, in extract_commit_hash
    search = re.search(r"snapshots/([^/]+)/", resolved_file)
  File "/home/snarenthiran/anaconda3/lib/python3.9/re.py", line 201, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object
```

### Expected behavior

To create the tokenizer from the local files.