# What does this PR do?

Fix  #24873

For example, we can pass `use_cache=True` (or set this in config) to `BartForSequenceClassification` and it will return `past_key_values` (although not useful to the task).

This is to respond to #24873, despite the memory issue reported there is not 100% for sure yet.
However, avoid using `cache` and not to let model returning `past_key_values` can avoid overhead like CPU/GPU communication (huge/many tensors).

In the code snippet I provided in #24873, there is a gain of 16.5% of running time.

We could probably extend this PR to other pipeline task classes.

Avoid some pipeline tasks to use `use_cache=True`. # What does this PR do?

Fix  #24873

For example, we can pass `use_cache=True` (or set this in config) to `BartForSequenceClassification` and it will return `past_key_values` (although not useful to the task).

This is to respond to #24873, despite the memory issue reported there is not 100% for sure yet.
However, avoid using `cache` and not to let model returning `past_key_values` can avoid overhead like CPU/GPU communication (huge/many tensors).

In the code snippet I provided in #24873, there is a gain of 16.5% of running time.

We could probably extend this PR to other pipeline task classes.
