TFRemBertModelTest.test_resize_token_embeddings not working
Author: ydshieh
Pull request: no
Labels: name: WIP

name: bug

### System Info

```shell
- `transformers` version: 4.20.0.dev0
- Platform: Windows-10-10.0.22000-SP0
- Python version: 3.9.11
- Huggingface_hub version: 0.5.1
- PyTorch version (GPU?): 1.11.0+cu113 (True)
- Tensorflow version (GPU?): 2.8.0 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No
```


### Who can help?

@gante @Rocketknight1 

### Reproduction

`TFRemBertModelTest.test_resize_token_embeddings` has CI failed [here](https://github.com/huggingface/transformers/runs/6682139350?check_suite_focus=true)

This method (called during `resize_token_embeddings`)
https://github.com/huggingface/transformers/blob/028d4b7c8be2c2fc1146fcc1e9bd253c1a7ea346/src/transformers/modeling_tf_utils.py#L1449
assumes that `word_embedding_weight` has the same shape as `old_lm_head_decoder`, but this is not the case for `TFRemBertModel`, as it has `input_embedding_size` and `output_embedding_size` in config.

An PR #17511 was opened, but we decided to not merge it. Instead, a cleaning up of  TF embeddings should be done first.

### Expected behavior

```shell
`resize_token_embeddings` should work for `TFRemBertModelTest`
```


Comments:
@gante Feel free to add WIP tag :-)

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.

Hi @ydshieh, I was able to reproduce the issue by running `python -m pytest -n auto --dist=loadfile -s -v ./tests/models/rembert` from the root directory on the latest transfomers version v4.23.1. The `test_resize_token_embeddings` on `TFRemBertModelTest` seemed to pass now without the merged code from https://github.com/huggingface/transformers/pull/17511. By any chance the cleanup of TF embeddings has been done and we could now close this issue? Let me know if I miss anything.

**Test output:**
```
tests/models/rembert/test_modeling_tf_rembert.py::TFRemBertModelTest::test_resize_token_embeddings If you want to use `TFRemBertForCausalLM` as a standalone, add `is_decoder=True.`
If you want to use `TFRemBertForCausalLM` as a standalone, add `is_decoder=True.`
If you want to use `TFRemBertForCausalLM` as a standalone, add `is_decoder=True.`

[gw1] PASSED tests/models/rembert/test_modeling_tf_rembert.py::TFRemBertModelTest::test_resize_token_embeddings
tests/models/rembert/test_modeling_tf_rembert.py::TFRemBertModelTest::test_save_load All model checkpoint layers were used when initializing TFRemBertModel.
```

Hi @katiele47 This test is still failing on our CI. Could you share your environment information, by running `python utils\print_env.py`. Also, could you share your hardware information (CPU, GPU) please? Thank you!

@ydshieh Sorry for the delay in response! This is what I got for environment (may ignore the last error):
```
Python version: 3.8.9 (default, Oct 26 2021, 07:25:54) 
[Clang 13.0.0 (clang-1300.0.29.30)]
transformers version: 4.24.0.dev0
Torch version: 1.12.1
Cuda available: False
Cuda version: None
CuDNN version: None
Number of GPUs available: 0
Traceback (most recent call last):
  File "utils/print_env.py", line 39, in <module>
    print("NCCL version:", torch.cuda.nccl.version())
  File "/Users/Bibi/transformers/menv/lib/python3.8/site-packages/torch/cuda/nccl.py", line 35, in version
    ver = torch._C._nccl_version()
AttributeError: module 'torch._C' has no attribute '_nccl_version'
``` 
GPU: Intel Iris Plus Graphics 1536 MB
CPU: 2 GHz Quad-Core Intel Core i5
Platform: Mac version 11.6

Let me know if you need any further information! Thanks.