fix: allow "inputs" as kwargs or positional arg
Author: Keredu
Pull request: yes

# What does this PR do?

<!--
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 # Pipelines didn't work when passing "inputs" as kwargs instead of positional arg. This is discussed in #26010


## 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/)? Yes, #26010.
- [ ] 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).
- [ ] Did you write any new necessary tests?


## Who can review?

@Narsil

<!-- 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:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @muellerz and @pacman100

Integrations:

- deepspeed: HF Trainer/Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization (bitsandbytes, autogpt): @SunMarc and @younesbelkada

Documentation: @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: See Models above and tag the person corresponding to the modality of the example.
- TensorFlow: @Rocketknight1

 -->


Comments:
When running something like the following script:
```python
from src.transformers.__init__ import pipeline

classifier = pipeline(
    task="sentiment-analysis",
    model="distilbert-base-uncased-finetuned-sst-2-english",
)

res = classifier("Hello world args", inputs="Hello world kwargs")

print(res)
```
it returns ``TypeError: Pipeline.__call__() got multiple values for argument 'inputs'`` which is right. Should we add something to control this case? I also happens if we use, for example, ``classifier(3, inputs="Hello world kwargs")`` where someone could try to use it as ``top_k=3`` and ``input="Hello world kwargs"`` 

> Hey! Would be easier for me to review if you add the tests now! (the 3 different cases you mention on the comment 😉

Of course, I could add as many tests as you consider necessary. However, I don't know what I should check exactly.

I mean, case 3 looks weird to me. That's because if I pass a string as an argument, it should return a dictionary. If I pass a list of strings, it should return a list of dictionaries. That's exactly what happened in case 1 and 2. However, case 3 always returns a list.

Do you want me to code the following tests?
1. When a string is passed, then its returned a dictionary
2. When a list of strings is passed then it's returned a list of dictionaries


Hey @keredu, sorry for the delay in responding!

Regarding tests, I would take your initial statement that failed with the current implementation and implement a test that ensures that it is now working. The rest of our tests should already ensure that your change doesn't break anything else.

> Hey @Keredu, sorry for the delay in responding!
> 
> Regarding tests, I would take your initial statement that failed with the current implementation and implement a test that ensures that it is now working. The rest of our tests should already ensure that your change doesn't break anything else.

Ok, I'll do it asap

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.

> Hey! Would be easier for me to review if you add the tests now! (the 3 different cases you mention on the comment 😉


Hello @LysandreJik, apologies for the delay; I've only now managed to allocate time to this.

I've added two tests. The first addresses the issue raised in #26010. The second covers the three scenarios we discussed. Essentially, when `top_k` is provided as a positional argument, it is disregarded. For instance, executing

```python
classifier("test_args_kwargs input string", 2)
```
triggers a console message: "Ignoring args: (2,)" confirming the behavior. If this disregard of the argument is indeed the expected behavior, I could remove the corresponding test. Please advise on whether this is necessary.

Please let me know if there are any other changes or additions needed.