Obtain the category codes from `CategoricalDtype`
```python
cat = pd.Categorical.from_codes([-1, 1, 2, 3, 4], ['-', 'a', 'b', 'c', 'd'])
print(cat.codes)
>>> array([-1,  1,  2,  3,  4], dtype=int8)
dtype = cat.dtype

dtype.codes
>>> Traceback (most recent call last):
>>>  File "<stdin>", line 1, in <module>
>>> AttributeError: 'CategoricalDtype' object has no attribute 'codes'

```
#### Problem description

Once a `pd.CategoricalDtype` is created, the codes (which are attached to `pd.Categorical`) are essentially gone. I am using another dataframe as data holder for categorical data and need to switch back and forth between code and label representation of categorical. Once a series is converted to categorical the `dtype` does not hold the code information any more.

This is where the codes go missing (`categories` was series with indices representing the codes, but only values are used to construct the `categories`).

```python
@staticmethod
    def validate_categories(categories, fastpath: bool = False):
        ...
        elif not isinstance(categories, ABCIndexClass):
            categories = Index(categories, tupleize_cols=False)
```

#### Expected Output

`dtype.codes` returns something, or even better don't differentiate between pd.Categorical and `pd.CategoricalDtype`.

#### Output of ``pd.show_versions()``

<details>

INSTALLED VERSIONS
------------------
commit           : None
python           : 3.7.6.final.0
python-bits      : 64
OS               : Linux
OS-release       : 5.4.17-200.fc31.x86_64
machine          : x86_64
processor        : x86_64
byteorder        : little
LC_ALL           : None
LANG             : en_AU.UTF-8
LOCALE           : en_AU.UTF-8

pandas           : 0.25.3
numpy            : 1.18.1
pytz             : 2019.3
dateutil         : 2.8.1
pip              : 19.3.1
setuptools       : 41.0.1
Cython           : 0.29.11
pytest           : 5.1.1
hypothesis       : None
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : 0.9.6
lxml.etree       : None
html5lib         : None
pymysql          : None
psycopg2         : 2.8.3 (dt dec pq3 ext lo64)
jinja2           : 2.9.6
IPython          : None
pandas_datareader: None
bs4              : None
bottleneck       : 1.3.1
fastparquet      : None
gcsfs            : None
lxml.etree       : None
matplotlib       : 2.2.4
numexpr          : 2.6.9
odfpy            : None
openpyxl         : 1.8.6
pandas_gbq       : None
pyarrow          : None
pytables         : None
s3fs             : None
scipy            : 1.1.0
sqlalchemy       : 1.3.12
tables           : 3.5.1
xarray           : None
xlrd             : 1.2.0
xlwt             : None
xlsxwriter       : 0.9.6

</details>
