Not work cache_dir of AutoTokenizer.from_pretrained('gpt2') 
### System Info

My transformers is version 4.11.3, python version is 3.8.5, and Ubuntu 20.04.1.


I want to know the cache directory when downloading AutoTokenizer.from_pretrained('gpt2') 
I run the below code
```
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('gpt2')
tokenizer.cache_dir
```
then, the result is `AttributeError` like
```python
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'GPT2TokenizerFast' object has no attribute 'cache_dir'
``` 
When run `tokenizer.cache_dir()` , the result is the same `AttributeError`.

The downloaded tokenizer is from CodeParrot.
CodeParrot is in `transformers/examples/research_projects/codeparrot/`, and `codeparrot/scripts/bpe_training.py` download `AutoTokenizer.from_pretrained('gpt2')`. 

How can I get the cache directory path of tokenizer??
What is my problems?

I want to know from method or variable of tokenizer, not the path.
(I already find ~/.cache/huggingface/transformers have cache files.)
If possible,  I would like to know for tokenizer how to use the three files, .json, .lock, and the last file with no extension.

### Who can help?

_No response_

### Information

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

### Tasks

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

### Reproduction

<img width="659" alt="Screenshot 2023-04-18 at 6 37 54 PM" src="https://user-images.githubusercontent.com/62585026/232737073-b317ae95-5ce8-4545-99c8-9239ed39d29c.png">

The tokenizer code in CodeParrot.
My running code is 
<img width="470" alt="Screenshot 2023-04-18 at 6 38 32 PM" src="https://user-images.githubusercontent.com/62585026/232737239-a7b51916-4d9b-4e9e-ae99-fba31abf0f1c.png">
and scripts/bpe_training.py code is
<img width="722" alt="Screenshot 2023-04-18 at 6 39 41 PM" src="https://user-images.githubusercontent.com/62585026/232737566-d70052e3-9ed4-40ab-9ef6-1030a80a36a4.png">


### Expected behavior

I want to get the cache directory path of downloaded tokenizer.
I want to know from method or variable of tokenizer, not the path.
(I already find ~/.cache/huggingface/transformers have cache files.)

Moreover, if possible, I would like to know how to use the three files, .json, .lock, and the last file with no extension.
Hi @irene622, thanks for raising this issue! 

`cache_dir` isn't an attribute of the class, and so calling `tokenizer.cache_dir` will raise an error. 

You can find the cache directory, importing from utils: 
```python
from transformers.utils import TRANSFORMERS_CACHE
```

When a tokenizer is created, should have the `name_or_path` attribute set, which will tell you from which model repo, or path it was loaded from. 
```python
>>> from transformers import AutoTokenizer
>>> tokenizer = AutoTokenizer.from_pretrained("xlm-mlm-en-2048")
>>> tokenizer.name_or_path
'xlm-mlm-en-2048'
```<|||||>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.