custom stopping_critriea function doesn't receive logits scores (receives None instead)
Author: Gandalf098
Pull request: no
Labels: name: WIP

### System Info

- `transformers` version: 4.29.2
- Platform: Linux-5.15.107+-x86_64-with-glibc2.31
- Python version: 3.10.11
- Huggingface_hub version: 0.14.1
- Safetensors version: not installed
- PyTorch version (GPU?): 2.0.1+cu118 (True)
- Tensorflow version (GPU?): 2.12.0 (True)
- Flax version (CPU?/GPU?/TPU?): 0.6.9 (gpu)
- Jax version: 0.4.8
- JaxLib version: 0.4.7
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help?

_No response_

### Information

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

### Tasks

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

### Reproduction

Reproduction Steps:

1. Initialize a BART model & its tokenizer (in my case it is facebook/bart-large)
2. Create a custom stopping_criteria function and add it to StoppingCriteriaList object
3. Run model.generate() with the your stopping criteria list as argument

Scores argument is always None

Example code:
```python
import torch
from transformers import StoppingCriteriaList, BartForConditionalGeneration, BartTokenizer

def custom_stopping_criteria(input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
    print ("Scores:", scores)
    return False

stopping_criteria = StoppingCriteriaList([custom_stopping_criteria])

model = BartForConditionalGeneration.from_pretrained("facebook/bart-large", forced_bos_token_id=0)
tok = BartTokenizer.from_pretrained("facebook/bart-large")

example_english_phrase = "UN Chief Says There Is No <mask> in Syria"
batch = tok(example_english_phrase, return_tensors="pt")

model.generate(batch["input_ids"], stopping_criteria=stopping_criteria)
```

The above code uses a stopping critriea that just prints the scores value when called (which prints None)

### Expected behavior

The expected behavior should be to have Scores logits populated with values instead of being None (values before or after softmax don't matter)

Comments:
cc @gante 

Hey @Gandalf098 (the white, I hope ;) )

By default, the scores are not initialized and are kept as `None` (see [here](https://github.com/huggingface/transformers/blob/5fa0a1b23b6a79eb646636dbf9a22cb34ff48a74/src/transformers/generation/utils.py#L2308)). To enable score-keeping, you must pass `return_dict_in_generate=True, output_scores=True` to your `.generate()` call.

____________________________________________

```py
import torch
from transformers import StoppingCriteriaList, BartForConditionalGeneration, BartTokenizer

def custom_stopping_criteria(input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
    print("Scores:", scores)
    return False

stopping_criteria = StoppingCriteriaList([custom_stopping_criteria])

model = BartForConditionalGeneration.from_pretrained("facebook/bart-large", forced_bos_token_id=0)
tok = BartTokenizer.from_pretrained("facebook/bart-large")

example_english_phrase = "UN Chief Says There Is No <mask> in Syria"
batch = tok(example_english_phrase, return_tensors="pt")

model.generate(batch["input_ids"], stopping_criteria=stopping_criteria, return_dict_in_generate=True, output_scores=True)
```

Hi @gante and @Gandalf098,

According to the `StoppingCriteria.__call__` [signature](https://huggingface.co/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.StoppingCriteria) and to its docstring, `scores` is supposed to be a `torch.FloatTensor`.
> scores (torch.FloatTensor of shape (batch_size, config.vocab_size)) — Prediction scores of a language modeling head.


It makes sense to think of it as the **last** prediction scores of the language modeling head, meaning that the score-keeping here refers not to `score` (optional history of the prediction scores) but to `next_token_scores` (always available last prediction scores - at least for [greedy decoding](https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/generation/utils.py#L2400-L2401), we should verify for other decoding strategies). 

In that sense, I do think we should correct this point. What do you think @gante?


We might want to build some stopping criteria based on a sequence of tokens/sequence of scores, so this API is more general 🤗 

We do need better docs and/or input validation, though, to detect these issues in advance. It is my priority for this month (and I'm keeping this issue open so I don't forget to address this case)