Refactor proposition for multiple choice models
Author: sgugger
Pull request: yes
Labels: name: wontfix

Opening the discussion about refactoring the dupe code in all task-specific models. This is a proposal of design that still leaves the specific classes and their docstrings, does not change the name of their attributes for backward compatibility but delegates the actual forward method to a task-specific method in `PreTrainedModel`.

This is the initial development to get feedback and suggestions for improvements :-)

An alternative is to have directly a model with multiple choice built for any architecture that supports the task. Explored that in [this gist](https://gist.github.com/sgugger/edc345943c92b155e0d73ef7a1897c21) if you want to see what it could look like. The main problem with this approach is that the model-specific arguments get hidden in kwargs, not sure if this is a blocker or not.

Comments:
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/4944?src=pr&el=h1) Report
> Merging [#4944](https://codecov.io/gh/huggingface/transformers/pull/4944?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/473808da0d476792070f0e7dfebcf1121a12a34f&el=desc) will **decrease** coverage by `0.03%`.
> The diff coverage is `91.66%`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/4944/graphs/tree.svg?width=650&height=150&src=pr&token=9qOlN6Hb1c)](https://codecov.io/gh/huggingface/transformers/pull/4944?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #4944      +/-   ##
==========================================
- Coverage   77.14%   77.11%   -0.04%     
==========================================
  Files         128      128              
  Lines       21745    21713      -32     
==========================================
- Hits        16775    16743      -32     
  Misses       4970     4970              
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/4944?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/modeling\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/4944/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ191dGlscy5weQ==) | `90.48% <90.00%> (-0.02%)` | :arrow_down: |
| [src/transformers/modeling\_bert.py](https://codecov.io/gh/huggingface/transformers/pull/4944/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19iZXJ0LnB5) | `87.86% <100.00%> (-0.33%)` | :arrow_down: |
| [src/transformers/modeling\_longformer.py](https://codecov.io/gh/huggingface/transformers/pull/4944/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19sb25nZm9ybWVyLnB5) | `92.75% <100.00%> (-0.28%)` | :arrow_down: |
| [src/transformers/modeling\_roberta.py](https://codecov.io/gh/huggingface/transformers/pull/4944/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ19yb2JlcnRhLnB5) | `94.35% <100.00%> (-0.43%)` | :arrow_down: |
| [src/transformers/modeling\_xlnet.py](https://codecov.io/gh/huggingface/transformers/pull/4944/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ194bG5ldC5weQ==) | `76.26% <100.00%> (-0.10%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/4944/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl91dGlscy5weQ==) | `87.42% <0.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/4944?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/4944?src=pr&el=footer). Last update [473808d...95d5bad](https://codecov.io/gh/huggingface/transformers/pull/4944?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.