Adding OPTForSeqClassification class
Author: oneraghavan
Pull request: yes

# What does this PR do?
It add the class for OPTForSequenceClassification based on OPT model 
<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes #17525 


## 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?
- [x] 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.
- [x] 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).
- [x] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @LysandreJik

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->


Comments:
_The documentation is not available anymore as the PR was closed or merged._

Not sure how to make these failing test pass. Need help

The following three test are failing :

FAILED tests/models/opt/test_modeling_opt.py::OPTModelTest::test_load_with_mismatched_shapes - AssertionError: RuntimeError not raised
FAILED tests/models/opt/test_modeling_opt.py::OPTModelTest::test_model_common_attributes - NotImplementedError
FAILED tests/models/opt/test_modeling_opt.py::OPTModelTest::test_resize_tokens_embeddings - NotImplementedError

Need help on how to fix them .

@NielsRogge Can you help me on how to fix the tests?


@ArthurZucker  Please point on how to fix these errors

Hey, thanks a lot for this PR ! sorry for the delay I was OOO. 2 of the failed tests are quite simple to solve, it seems that the class is missing a function `get_input_embeddings`. 
One test is probably unrelated to your PR : `PegasusStandaloneDecoderModelTest` for that I would just recommend  merging the latest updates from the main branch. 
I would have to dig a little bit deeper for the last test `OPTModelTest.test_load_with_mismatched_shapes` but it might be related to a missing `set_input_embedding` function, will check that 

@younesbelkada Some tests are failing due to same model(OPTForSeqClassification) available in torch not available for tensorflow. Should I add it part of this PR ? 

Can we close this PR and I will raise another PR with TFOPTForSeqClassification ? 

Hey @oneraghavan !
Thanks for your comment, I am not sure if not having `TFOPTForSeqClassification` explains why those tests are failing since the test should not return nothing [here](https://github.com/oneraghavan/transformers/blob/d672d9c54a5a329220a8dabb6b6e3f961fbdca5b/tests/test_modeling_common.py#L1767). 
The error says `AttributeError: decoder.embed_tokens.weight not found in TF 2.0 model` so it might be possible that the modifications you made on `OPTModel` and `OPTPretrainedModel` classes broke those tests. 
Also the git history seems to be broken, could you please rebase to main or merge with force-push to clean the git histoiry (aka the number of modified files has increased) 💪 
Thanks again for your help here! And let us know if anything is unclear or if you need any help

Hey, I think the history is a bit messed up but it is alright (issues with merging I guess). Also, we should not have to change the `OPTPretrainedModel` base prefix. This can be a backward compatibility issue and should definitely be avoided. If you could just revert on that change it would be great. I think that it will solve the failing test and we will be able to merge 👍🏻  

> Hey @oneraghavan ! Thanks for your comment, I am not sure if not having `TFOPTForSeqClassification` explains why those tests are failing since the test should not return nothing [here](https://github.com/oneraghavan/transformers/blob/d672d9c54a5a329220a8dabb6b6e3f961fbdca5b/tests/test_modeling_common.py#L1767). The error says `AttributeError: decoder.embed_tokens.weight not found in TF 2.0 model` so it might be possible that the modifications you made on `OPTModel` and `OPTPretrainedModel` classes broke those tests. Also the git history seems to be broken, could you please rebase to main or merge with force-push to clean the git histoiry (aka the number of modified files has increased) 💪 Thanks again for your help here! And let us know if anything is unclear or if you need any help

I Tried to do pull rebase from my main to huggingface repo. How do you want me to leave this PR? Just leave my commits on top ? 

@ArthurZucker All tests fixed, we can close this PR.

> Looks good! Only left a comment regarding one addition.

Done

Hey @oneraghavan do you have any checkpoints we could use for the documentation? It seems that you added some expected loss value and expected outputs, wanted to know if we can maybe use the model checkpoints for documentation (otherwise it is totally ok! I will use a dummy model 😄 )

@ArthurZucker  I do not have any checkpoints, I used a dummy model.