Enhanced Parameter Freezing Capabilities in Trainer Class
### Feature request

The feature proposal aims to introduce a more streamlined and intuitive approach to freezing and unfreezing specific model components directly in the Trainer class of the Hugging Face transformers library.

### Motivation

I've found that when I need to freeze certain parameters or components of my models, the process can be a bit complicated.

Currently, I need to set requires_grad to False for the parameters I want to freeze before calling Trainer.train(). But since Trainer.train() calls model.train() before the training loop, some parameters (e.g., running mean and running var of BatchNorm layers) will still change during training. To get around this, I have to implement additional flags in my model and manually call model.eval() in the forward function for the parts of the model I want to freeze.

It would be great if there was a more streamlined way to accomplish this directly in the Trainer class. Maybe an additional argument in the Trainer.train() method, or a method in the Trainer class to freeze/unfreeze specified layers or parameters. This could make fine-tuning models easier and more intuitive, particularly for new users or those with less experience in PyTorch.

### Your contribution

I am glad to offer help.
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.