Unable to retrieve layers from model in tensorflow
### System Info

```shell
transformers version: 4.18.0
platform: Google Colab
python version: 3.7.13
```


### Who can help?

@Rocketknight1 
I am training a Roberta-large model for a classification task and I am using pre-trained model to start with. But for my task I want to freeze the embedding layer and the first few encoding layers, so that I can fine-tune the attention weights of the last few encoding layers. But I cannot access the layers while using tensorflow. 


### 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

from transformers import RobertaTokenizer, TFRobertaModel
import tensorflow as tf
model = TFRobertaModel.from_pretrained('roberta-large')
model.get_layer(2)

### Expected behavior

```shell
This should have returned a layer instance but rather throws error
`ValueError: Was asked to retrieve layer at index 10 but model only has 1 layers.`
```

Unfortunately, this method probably won't work for our models, because we implement the core of the model as a `MainLayer` class, and so the actual `Model` generally only has one "layer". In addition, our models and layers are implemented by subclassing, which means the order of the layers is not well-defined.

If you want to access sub-layers, you'll need to use [the actual Python structure of the class](https://github.com/huggingface/transformers/blob/main/src/transformers/models/roberta/modeling_tf_roberta.py#L912), rather than Keras methods. So `model.roberta.embeddings` will give you the embedding layer, and `model.roberta.encoder.layer` will give you a list of the other model layers. [Depending on your model](https://github.com/huggingface/transformers/blob/a42242da7c44d64c66a878cca65bc86dd3f626af/src/transformers/models/roberta/modeling_tf_roberta.py#L587-L590), there may also be a `model.roberta.pooler`.<|||||>Ah!
Thanks for the clarification!