add initial design for uniform processors + align model
Author: molbap
Pull request: yes
Labels: name: run-slow

# What does this PR do?

Adds a uniform signature for processors. This PR adds the initial design + one model for the larger #30511.

## Usage

As before, kwargs that are passed to processors at `__call__` time take priority. However, per-modality processors can be instantiated with their own kwargs, and if they are not overriden at call time, they will serve as defaults. 

Type hinting of kwargs is preserved if they are passed as structured dictionary entries
![image](https://github.com/huggingface/transformers/assets/39954772/c859e4b0-5c08-49c6-bd65-6e71d3f6c9f0)

It also works with kwargs passed without nesting:
![image](https://github.com/huggingface/transformers/assets/39954772/aa675d30-ca45-466a-86c9-41066a064c60)

Merging of kwargs and handling priority order is done in `processing_utils` through a dedicated method. 
The order of operations is as follows:
1) kwargs passed as before have highest priority to preserve BC.
```python
high_priority_kwargs = {"crop_size" = (224, 224), "padding" = "max_length"}
processor(..., **high_priority_kwargs)
```
2) kwargs passed as modality-specific kwargs have second priority. This is the recommended API.
```python
processor(..., text_kwargs={"padding": "max_length"}, images_kwargs={"crop_size": (224, 224)}})
```
3) kwargs passed during instantiation of a modality processor have fourth priority.
```python
tokenizer = tokenizer_class(..., {"padding": "max_length"})
image_processor = image_processor_class(...)
processor(tokenizer, image_processor) # will pass max_length unless overriden by kwargs at call
```
4) defaults kwargs specified at processor level have lowest priority.

```python
class MyProcessingKwargs(ProcessingKwargs, CommonKwargs, TextKwargs, ImagesKwargs, total=False):
    _defaults = {
        "text_kwargs": {
            "padding": "max_length",
            "max_length": 64,
        },
    }
```

## Missing:

- [x] Move tests of kwargs checking to a common util


Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_31197). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

cc @amyeroberts for a review with a narrower scope than the parent PR :grin: 

cc @amyeroberts, sorry to divide my pings :sweat_smile: PR is big and I wanted to split it up, this one should be merge-able and be the basis for the rest, I'll rebase afterwards (and @qubvel welcome if you want to take a look!)

It includes the kwargs merging just mentioned in the other PR, moved them to processing common!

@molbap OK, sounds good! Let's wait for @qubvel's eagle eye. Once tests are added, ping me again for a final review 🤗 

I have updated the PR description to be more self-contained: by using `typing_extensions` the imports for `Unpack` work, but type hinting doesn't for versions of python < 3.11. Functionality, though, is preserved for older versions I tested. 

@amyeroberts (and @qubvel !) you might want to take another look! I updated the PR description as mentioned above. the tests to check tokenizer_init need to be "global-ized", right now the `ProcessorTesterMixin` is only used in one other model. The tests do exist and are model-specific for now. I can add them in this PR or another one, no strong opinion :) 

[EDIT]: I added the tests to a common Mixin so they're easier to extend to all other models!

@amyeroberts FYI Kept digging for the kwargs merging logic, and found an edge case that was giving unreliable results in the tokenizer. Refactored and doubled number of tests to avoid further trickery (including an edge case found earlier by @qubvel ), logic should be easier to read now. Nothing else changed, and tests should pass reliably.