how to frozen TFGPT2LMHeadModel Embedding matrix?
### System Info

when i use the TFGPT2LMHeadModel structure to train, i want to frozen the embedding matrix, how can i do it?@patil-suraj

### Who can help?

_No response_

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

config = AutoConfig.from_pretrained(pretrained_model_path,vocab_size=VOCAB_SIZE, n_positions=MAX_SEQ_LEN, n_ctx=MAX_SEQ_LEN, n_layer=1,  n_embd=384, initializer_range=0.002)#, initializer_range=0.002
        model = TFGPT2LMHeadModel.from_config(config)
        embedding = np.load(embed_data_path)
        model.set_input_embeddings(embedding)

### Expected behavior

help me to frozen embedding layer
Hi @Orient12 👋 As per our [issues guidelines](https://github.com/huggingface/transformers/blob/main/ISSUES.md), we reserve GitHub issues for bugs in the repository and/or feature requests. For any other matters, we'd like to invite you to use our [forum](https://discuss.huggingface.co/) 🤗

(You can set the `trainable` attribute of a layer to `False`, see [this guide](https://keras.io/guides/transfer_learning/#freezing-layers-understanding-the-trainable-attribute))<|||||>> 
Actually, class TFGPT2LMHeadModel model can not split by layer,it just have one layer, so i can't set embedding matrix trainable=False
<|||||>@Orient12 
Sure you can, you just need to know the right attribute names (for which you might need to dig through the code). The following snippet freezes the embedding layer.

```python
from transformers import TFGPT2LMHeadModel

model = TFGPT2LMHeadModel.from_pretrained("distilgpt2")
print(model.transformer.wte)
print(model.transformer.wte.trainable)

# setting embeddings to not trainable
model.transformer.wte.trainable = False
print(model.transformer.wte.trainable)
```

Our models do not use the Sequential nor the Functional API -- they use the [subclassing](https://keras.io/guides/making_new_layers_and_models_via_subclassing/) method.<|||||>Thanks for your help!I have known how to freeze it！<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.