

TITLE
Unable to retrieve layers from model in tensorflow

COMMENTS
2

REACTIONS
+1: 0
-1: 0
laugh: 0
hooray: 0
heart: 0
rocket: 0
eyes: 0

BODY
### 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.`
```
