Add mPLUG-Owl
Author: LukeForeverYoung
Pull request: yes

# What does this PR do?

This PR adds the mPLUG-Owl model from [X-PLUG/mPLUG-Owl](https://github.com/X-PLUG/mPLUG-Owl) which is a multi-modal large language model outperforms LLAVA and mini-GPT4.

Here is a code shows how to play with it:
```Python
from transformers import MplugOwlForConditionalGeneration, MplugOwlProcessor
from PIL import Image
import requests
import torch

model = MplugOwlForConditionalGeneration.from_pretrained("MAGAer13/mplug-owl-llama-7b")
processor = MplugOwlProcessor.from_pretrained("MAGAer13/mplug-owl-llama-7b")

prompts = [
'''The following is a conversation between a curious human and AI assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.
Human: <image>
Human: how many cats are there?
AI: ''']
image_list = ['http://images.cocodataset.org/val2017/000000039769.jpg']

images = [Image.open(requests.get(_, stream=True).raw) for _ in image_list]
inputs = processor(prompts, images, return_tensors='pt')
inputs = inputs.to('cuda')
model = model.to('cuda').half()
res = model.generate(**inputs, max_length=512, num_beams=1)
print(processor.decode(True,token_ids=res.tolist()[0]))
```

<!-- Remove if not applicable -->

Models:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts






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

> Thank you very much for this PR and adding this great model! Let us know when this is ready for review, I can see that a lot of CI tests are failing, you should resolve them by removing the `from .xxxx import *` statements in the init file of `mplug_owl` folder

I added some commits, but I noticed that there are still some failed tests. Among them, tests_torch reports an error "worker 'gw1' crashed while running 'tests/models/mplug_owl/test_modeling_mplug_owl.py::MplugOwlModelTest::test_forward_signature'", but I can pass this test in my local environment. I would like to seek some advice. 
In addition, for other tests such as tests_flax, is it necessary for me to pass them?


> I added some commits, but I noticed that there are still some failed tests. Among them, tests_torch reports an error "worker 'gw1' crashed while running 'tests/models/mplug_owl/test_modeling_mplug_owl.py::MplugOwlModelTest::test_forward_signature'", but I can pass this test in my local environment. I would like to seek some advice. 

The job ran out of the available RAM as seen in the picture below.
<img width="1052" alt="Screenshot 2023-05-19 064910" src="https://github.com/huggingface/transformers/assets/2521628/04049d9b-84d0-4cfd-bba4-6f82a6081628">
Note that the CI launched 3 pytest process instead of a single one, so it will use more memory. Also, our CI runner has only 16GB RAM, which might be different from you hardware.

The crash here means you might use (some) large values in the test file to create the models that are used for testing.

> In addition, for other tests such as tests_flax, is it necessary for me to pass them?

Depending on what kinds of failure. If it is something like import error, yes, we expect the contributor to fix and pass the CI :-). If it is something like Hub Connection error, it's fine, we can leave it.



> > I added some commits, but I noticed that there are still some failed tests. Among them, tests_torch reports an error "worker 'gw1' crashed while running 'tests/models/mplug_owl/test_modeling_mplug_owl.py::MplugOwlModelTest::test_forward_signature'", but I can pass this test in my local environment. I would like to seek some advice.
> 
> The job ran out of the available RAM as seen in the picture below. <img alt="Screenshot 2023-05-19 064910" width="1052" src="https://user-images.githubusercontent.com/2521628/239440445-04049d9b-84d0-4cfd-bba4-6f82a6081628.png"> Note that the CI launched 3 pytest process instead of a single one, so it will use more memory. Also, our CI runner has only 16GB RAM, which might be different from you hardware.
> 
> The crash here means you might use (some) large values in the test file to create the models that are used for testing.
> 
> > In addition, for other tests such as tests_flax, is it necessary for me to pass them?
> 
> Depending on what kinds of failure. If it is something like import error, yes, we expect the contributor to fix and pass the CI :-). If it is something like Hub Connection error, it's fine, we can leave it.

Thank you for your help, now all the checks have passed.

Awesome @LukeForeverYoung !
Is the PR ready for a first review?

> Awesome @LukeForeverYoung !
> Is the PR ready for a first review?

Yes

> Hi @LukeForeverYoung Let us know if you need any help finishing up the PR and if you have more questions!

Sorry for not being able to reply recently. Our team has been swamped with work, which causing that the process of integrating mPLUG-Owl into transformers may be paused for a long time. Thank you very much for your review. It would be great if anyone is willing to take over.

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.