Config parameters for custom models

Hi everyone,

I’ve faced a problem regarding the configuration parameters of a custom model (say distilbert). To elaborate, let’s give an example:
Suppose we want to perform the text classification task. For this purpose, we have 2 approaches:

  1. we can directly use DistilBertForSequenceClassification in hugging face modules (and just change the number of output in classifier):
    model = DistilBertForSequenceClassification.from_pretrained('distilbert-base-uncased')

  2. write a custom model and define a specific classification head:

soal

In the first approach, model.config gives the configuration of the model, but in the second, it rises an error: 'Distilbert' object has no attribute 'config'.
The question is, why does this happen?!

Thanks