TFGPT2ForSequenceClassification.from_pretrained with num_labels parameter creates a model with reversed layers order
### System Info

platform: macos, m1 max
python version: 3.9.13
transformers version: 4.25.1

### Who can help?

@Rocketknight1 

### Information

- [X] 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

The following code:

```python
from transformers import GPT2Tokenizer, TFGPT2ForSequenceClassification
model = TFGPT2ForSequenceClassification.from_pretrained('gpt2-medium', num_labels=30)
model.summary()
```

It shows then:
```
Model: "tfgpt2_for_sequence_classification_7"
_________________________________________________________________
 Layer (type)                Output Shape              Param #   
=================================================================
 score (Dense)               multiple                  30720     
                                                                 
 transformer (TFGPT2MainLaye  multiple                 354823168 
 r)                                                              
                                                                 
=================================================================
Total params: 354,853,888
Trainable params: 354,853,888
Non-trainable params: 0

```
So as you can see dense layer goes before transformer layer, it should be opposite.

Also there is a Colab link: https://colab.research.google.com/drive/1MeNzHHXnccLAkNlSRpWELQhWF5Y7aIyS#scrollTo=hIbZMVd7xumr


### Expected behavior

I think that the dense layer should go after the transformer layer so that model could be trained. Looks like that something like this has been brought up some time ago:

https://github.com/huggingface/transformers/issues/11515
Hi @justnoxx 👋 

The layers are being called in the expected order, as you can see in the [model's forward pass](https://github.com/huggingface/transformers/blob/bbcd961897aa6cc439ef4cca5cef6db4283c5b76/src/transformers/models/gpt2/modeling_tf_gpt2.py#L1139). 

`model.summary()` is not fully compatible with our models because we rely on [Keras model subclassing](https://keras.io/api/models/), as opposed to Keras sequential/functional API (whose `model.summary()` produces the expected output).<|||||>@gante now I see it, thanks a lot for your help. Closing this issue now.