`warning_once` call crashes
Author: youroff
Pull request: no
Labels: name: Core: Pipeline

name: Good First Issue

### System Info

The issue seems to be present in main

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

Calling a pipeline in a cycle makes `.call_count` increment and eventually causes a `warning_once` which crashes due to wrong arguments provided here: https://github.com/huggingface/transformers/blob/main/src/transformers/pipelines/base.py#L1181

### Expected behavior

It shouldn't crash I guess...

Comments:
Hi @youroff, thanks for raising an issue! 

So that we can best help you, could you provide: 
* The running environment: run `transformers-cli env` in the terminal and copy-paste the output
* A minimal reproducible snippet we can run to replicate the error? For example, showing exactly what you mean by calling a pipeline in a cycle

I'm not sure if env is relevant here (but I'll try to get the output from the engineer who's integrating the pipeline). I posted a link to the place where the crash happens, and it's pretty obvious why it happens:
```
            logger.warning_once(
                "You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a"
                " dataset",
                UserWarning,
            )
```
The call doesn't seem to match the signature and it crashes with a trace like this: 
```
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/logging/__init__.py", line 1100, in emit
    msg = self.format(record)
  File "/opt/conda/lib/python3.10/logging/__init__.py", line 943, in format
    return fmt.format(record)
  File "/opt/conda/lib/python3.10/logging/__init__.py", line 678, in format
    record.message = record.getMessage()
  File "/opt/conda/lib/python3.10/logging/__init__.py", line 368, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting

File "/opt/conda/lib/python3.10/site-packages/transformers/pipelines/automatic_speech_recognition.py", line 285, in __call__
return super().__call__(inputs, **kwargs)
File "/opt/conda/lib/python3.10/site-packages/transformers/pipelines/base.py", line 1167, in __call__
logger.warning_once(
File "/opt/conda/lib/python3.10/site-packages/transformers/utils/logging.py", line 329, in warning_once
self.warning(*args, **kwargs)
Message: 'You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset'
Arguments: (<class 'UserWarning'>,)
```

I would guess that `UserWarning,` just needs to be removed and that will fix it, but I don't know why it was placed there in the first place.

And by running in a cycle I meant something like this:
```
model = pipeline(....)
while True:
    message = pull_message()
    model(message)
```
I'm not sure if the original warning and the recommendation to use a dataset are relevant for this use case.

> I'm not sure if env is relevant here

We ask all contributors to include information about the running environment when creating an issue and is part of the [issue template](https://github.com/huggingface/transformers/blob/main/.github/ISSUE_TEMPLATE/bug-report.yml). You can get this easily by running `transformers-cli env` in the terminal and copy-pasting the output

There are many reasons for this, the main ones being to ensure we can replicate and for any one in the future who comes to this issue. We have lots of issue and pull requests created everyday. In order for use to go through these in a timely manner,  we need you to help us help you. Part of this is providing the requested information. 

> and it's pretty obvious why it happens:

If it's obvious feel free to open a PR with a fix 

Here you go:
```
- `transformers` version: 4.39.3
- Platform: Linux-6.1.58+-x86_64-with-glibc2.31
- Python version: 3.10.13
- Huggingface_hub version: 0.22.2
- Safetensors version: 0.4.2
- Accelerate version: 0.29.1
- Accelerate config: 	not found
- PyTorch version (GPU?): 2.1.1 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>
```

Would certainly do that, but Python is not my main language and I don't feel skilled enough to contribute to a major repository. In this particular instance I have a hypothesis why it's crashing, but no understanding  why the call in question was composed the way it was composed.