Problem of computing entropy in `run_bertology.py`
### System Info

- `transformers` version: 4.20.1
- Platform: macOS-12.4-arm64-arm-64bit
- Python version: 3.9.10
- Huggingface_hub version: 0.8.1
- PyTorch version (GPU?): 1.13.0.dev20220709 (False)
- 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?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

@sgugger @thomwolf @stas00 @patrickvonplaten @LysandreJik   Many thanks!

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

In [`run_bertology.py` ](https://github.com/huggingface/transformers/blob/main/examples/research_projects/bertology/run_bertology.py#L108), we use `def entropy` to calculate the `entropy`  of attention matrix. But what if the matrix has negative elements, the `plogp = p * torch.log(p)` will be `nan`

### Expected behavior

`plogp = p * torch.log(p)` will be `nan`
Note that this is a research project, so an example provided as is not really maintained :-)<|||||>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.