Inference with a Dataset using pipeline in a tokenclassification job causes a ValueError("At least one input is required.")
Author: bengshaoye
Pull request: no

I can see that TokenClassificationPipeline was initialized  in "transformers.pipelines.__init__.py", but when a dataset was used as inputs, it will first parse arguments using "_inputs, offset_mappings = self._args_parser(inputs, **kwargs)"  , where a dataset is not allowed.
 If a list[str]-like object was used as inputs, the arguments parsing code can pass, but  Pipeline's __call__ method called next will print  a warning info ("You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset").

So, would anybody show me how to use a pipeline with GPU more efficiently? Thanks a lot.

## Environment info
- `transformers` version:   4.12.3
- Platform:  Ubuntu 20.04.3 LTS
- Python version: 3.8
- PyTorch version (GPU?):  GPU
- Tensorflow version (GPU?):  2.6
- Using GPU in script?:  Yes
- Using distributed or parallel set-up in script?:  No

### Who can help
@Narsil @LysandreJik 

## Information

Model I am using : 
Bert 

The tasks I am working on is:
* [x] an official GLUE/SQUaD task: ner

## To reproduce

Steps to reproduce the behavior:

1. initialize a pipeline:  nlp =  pipeline('ner',model=model,tokenizer=tokenizer,device=0)
2. define a torch Dataset and initialize an user object of this self defined Dataset 
3. call pipeline and pass the dataset to it.


Comments:
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/master/CONTRIBUTING.md) are likely to be ignored.

Hi @bengshaoye ,

This went off my radar for some reason. Do you have a reproducible script ?

Your steps to reproduce are not necessarily enough to understand the issue since the `Dataset` is not specified.

For the pipeline to work, you need a `Dataset` that return the object expected (Here a simple string, not a dict for instance).

Does that help ?

# here comes the code to reproduce.
from torch.utils.data import Dataset
from transformers import pipeline

class MyDataset(Dataset):
    def __init__(self,x):
        self.samples = x
        super().__init__()
    def __getitem__(self,index):
        return self.samples[index]
    def __len__(self):
        return len(self.samples)

str_input = 'Christoph Seubert, MD PhD DABNM'
# make a Dataset input
X = MyDataset([str_input]*100)

# here set pipeline instance to GPU
nlp = pipeline('ner',device=1)

# call nlp object with single str,  no error no warning
res = nlp('Christoph Seubert, MD PhD DABNM')

# call nlp object more than 10 times, a warning will show
# UserWarning: You seem to be using the pipelines sequentially on GPU. In order to maximize efficiency please use a dataset
for i in range(11):
    res = nlp(str_input)

# but if you call nlp like below, a valueerror will show
# ValueError: At least one input is required.
res = nlp(X)

Thanks for the script, was so simple I was persuaded this was covered in tests, this is obviously not the case. I added a PR to fix this.

I have the same problem, could you pls help me ?
I want to test much data ,about 2 billion to infer with the NER model([official script ](https://github.com/huggingface/transformers/blob/main/examples/pytorch/token-classification/run_ner.py))