[WIP] Introduce NestLayer
Author: amyeroberts
Pull request: yes
Labels: name: WIP

# What does this PR do?

Outline for a new layer class to replace `tf.keras.layers.Layer` in our models. It extends `tf.keras.layers.Layer` to include two methods `get_layer` and `layers` from `tf.keras.Model`.

## Motivation

All of our TF models' layers are subclasses of `tf.keras.layers.Layer`. Unfortunately, when there are nested layers, we are not able to access the layers below the first level using the typical keras `layers` API. 

The main reason for introducing to be able to use our models as backbones. In DETR, we replace the ResNet backbone's [batchnorm layers to frozen batchnorm layers](https://github.com/huggingface/transformers/blob/2ab790e82d0759b667cd848a4d49e6ad65e15d59/src/transformers/models/detr/modeling_detr.py#L306). We need to be able to perform the same or similar operations on our TF models. This requires being able to access all of the layers, which is currently not possible. 

For example - our `TFResNetModel` will only show `TFResNetMainLayer` when we call `model.summary(expand_nested=True)` and `TFResNetMainLayer` has no property `layers`. 

```
In [1]: from transformers import TFResNetModel
In [2]: model_checkpoint = "microsoft/resnet-50"
In [3]: model = TFResNetModel.from_pretrained(model_checkpoint)
In [4]: model.summary(expand_nested=True)
Model: "tf_res_net_model"
_________________________________________________________________
 Layer (type)                Output Shape              Param #
=================================================================
 resnet (TFResNetMainLayer)  multiple                  23561152

=================================================================
Total params: 23,561,152
Trainable params: 23,508,032
Non-trainable params: 53,120
_________________________________________________________________

In [5]: model.layers
Out[5]: [<transformers.models.resnet.modeling_tf_resnet.TFResNetMainLayer at 0x17fb9daf0>]

In [6]: hasattr(model.layers[0], 'layers')
Out[6]: False
```

This is also necessary if we every want to be able to access the intermediate activation functions of our TF model.


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_18605). All of your documentation changes will be reflected on that endpoint.

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.