KeyphraseExtractionPipeline - Postprocessor - TypeError: postprocess() got an unexpected keyword argument 'all_outputs'
Author: eboraks
Pull request: no

### System Info

transformers version: 4.20.1
Platform: (GNU/Linux 5.15.90.1-microsoft-standard-WSL2 x86_64
Python version: 3.9.16
PyTorch version (GPU?): 2.0.0+cu118
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?: No
Using distributed or parallel set-up in script?: No


### Who can help?

I am trying to use a keyphrase extractor as described here - https://huggingface.co/ml6team/keyphrase-extraction-distilbert-inspec 
and I am getting the following error. I am assuming "all_outputs" parameter is deprecated, the question what should I change it with? 

@sgugger @luccailliau 

### Information

- [X] 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

Copy and paste the code from [model](https://huggingface.co/ml6team/keyphrase-extraction-distilbert-inspec) into a Python file

Here is the code. 
```
from transformers import (
    TokenClassificationPipeline,
    AutoModelForTokenClassification,
    AutoTokenizer,
)
from transformers.pipelines import AggregationStrategy
import numpy as np

# Define keyphrase extraction pipeline


class KeyphraseExtractionPipeline(TokenClassificationPipeline):
    def __init__(self, model, *args, **kwargs):
        super().__init__(
            model=AutoModelForTokenClassification.from_pretrained(model),
            tokenizer=AutoTokenizer.from_pretrained(model),
            *args,
            **kwargs
        )

    def postprocess(self, all_outputs):
        results = super().postprocess(
            all_outputs=all_outputs,
            aggregation_strategy=AggregationStrategy.FIRST,
        )
        return np.unique([result.get("word").strip() for result in results])


 # Load pipeline
model_name = "ml6team/keyphrase-extraction-distilbert-inspec"
extractor = KeyphraseExtractionPipeline(model=model_name)


# Inference
text = """
Keyphrase extraction is a technique in text analysis where you extract the
important keyphrases from a document. Thanks to these keyphrases humans can
understand the content of a text very quickly and easily without reading it
completely. Keyphrase extraction was first done primarily by human annotators,
who read the text in detail and then wrote down the most important keyphrases.
The disadvantage is that if you work with a lot of documents, this process
can take a lot of time. 

Here is where Artificial Intelligence comes in. Currently, classical machine
learning methods, that use statistical and linguistic features, are widely used
for the extraction process. Now with deep learning, it is possible to capture
the semantic meaning of a text even better than these classical methods.
Classical methods look at the frequency, occurrence and order of words
in the text, whereas these neural approaches can capture long-term
semantic dependencies and context of words in a text.
""".replace("\n", " ")

keyphrases = extractor(text)

print(keyphrases)

```

When running it, I am getting the following error

```
(hugface) eboraks@mittenwood:~/Projects/studynotes/notebooks$ python keyphrase.py 
Traceback (most recent call last):
  File "/home/eboraks/Projects/studynotes/notebooks/keyphrase.py", line 53, in <module>
    keyphrases = extractor(text)
  File "/home/eboraks/anaconda3/envs/hugface/lib/python3.9/site-packages/transformers/pipelines/token_classification.py", line 191, in __call__
    return super().__call__(inputs, **kwargs)
  File "/home/eboraks/anaconda3/envs/hugface/lib/python3.9/site-packages/transformers/pipelines/base.py", line 1043, in __call__
    return self.run_single(inputs, preprocess_params, forward_params, postprocess_params)
  File "/home/eboraks/anaconda3/envs/hugface/lib/python3.9/site-packages/transformers/pipelines/base.py", line 1051, in run_single
    outputs = self.postprocess(model_outputs, **postprocess_params)
  File "/home/eboraks/Projects/studynotes/notebooks/keyphrase.py", line 22, in postprocess
    results = super().postprocess(
TypeError: postprocess() got an unexpected keyword argument 'all_outputs'
(hugface) eboraks@mittenwood:~/Projects/studynotes/notebooks$ 
```

### Expected behavior

# Output
['artificial intelligence' 'classical machine learning' 'deep learning'
 'keyphrase extraction' 'linguistic features' 'statistical'
 'text analysis']

Comments:
Hello @eboraks,

Since the release of Hugging Face 4.28.0, the `postprocess()` method has changed to handle unlimited length of text. Therefore, `all_outputs` can only be used if `transformers>=4.28.0`. I recommend updating transformers since you are using `transformers==4.20.1`.

If you can't upgrade to at least that specific version, renaming `all_outputs` to `model_outputs` should solve your problem:
```
def postprocess(self, model_outputs):
    results = super().postprocess(
        model_outputs=model_outputs,
        aggregation_strategy=AggregationStrategy.FIRST,
    )
    return np.unique([result.get("word").strip() for result in results])
```

Have a good day

Thank you @luccailliau upgrading to transformers 4.28 solved the issue.