Hidden states not available in S2T (and small typo in S2T documentation)
Author: gretatuckute
Pull request: no

## Environment info

- `transformers` version: 4.10.0
- Platform: macOS-10.15.7-x86_64-i386-64bit
- Python version: 3.8.11
- PyTorch version (GPU?): 1.9.0 (False)
- 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
@patrickvonplaten @LysandreJik

## Information
I am using S2T-SMALL-LIBRISPEECH-ASR (or any of the S2T models for that sake) and I am interested in outputting hidden states of the model (input: speech file, output: text), however, this is not returned in the forward (generate) pass.

## To reproduce
Steps to reproduce the behavior:

```
import torch
from transformers import Speech2TextProcessor, Speech2TextForConditionalGeneration
from datasets import load_dataset
import soundfile as sf

model = Speech2TextForConditionalGeneration.from_pretrained("facebook/s2t-small-librispeech-asr", output_hidden_states=True, return_dict=True)
processor = Speech2TextProcessor.from_pretrained("facebook/s2t-small-librispeech-asr")

def map_to_array(batch):
    speech, _ = sf.read(batch["file"])
    batch["speech"] = speech
    return batch

ds = load_dataset(
    "patrickvonplaten/librispeech_asr_dummy",
    "clean",
    split="validation"
)
ds = ds.map(map_to_array)

input_features = processor(
    ds["speech"][0],
    sampling_rate=16_000,
    return_tensors="pt"
).input_features  # Batch size 1
generated_ids = model.generate(input_ids=input_features)

transcription = processor.batch_decode(generated_ids)
```

## Expected behavior
I am expecting the model to return output_hidden_states (decoder_hidden_states, encoder_hidden_states), but these are not available. Is there some way of extracting the hidden states? 

Small note: processor = ```Speech2TextProcessor.from_pretrained("facebook/s2t-small-librispeech-asr")``` is misspelled in the documentation (https://huggingface.co/facebook/s2t-small-librispeech-asr) (small p in processor).

Thanks so much!!
Greta


Comments:
Hi,

The `.generate()` method is meant to generate text, it will not return hidden states. If you want those, you need to call `forward()` with `output_hidden_states=True`:

`outputs = model(input_ids=inputs["input_values"], attention_mask=inputs["attention_mask"], output_hidden_states=True)`



Hi Niels, thank you for your quick reply.

Continuing from the initial example, I can then call: 
 ```
input_features = processor(
    ds["speech"][0],
    sampling_rate=16_000,
    return_tensors="pt"
)

outputs = model.forward(input_features=inputs["input_features"], attention_mask=inputs["attention_mask"], output_hidden_states=True)

```

Which gives a ValueError: You have to specify either decoder_input_ids or decoder_inputs_embeds 
Which are listed as optional? 

Update: I just checked, the `.generate()` method also provides an argument `output_hidden_states` which can be set to `True`.

Great, thank you for this Niels! For reference, I also had to use the ```return_dict_in_generate``` flag to output the states. 

```
generated_ids = model.generate(input_ids=input_features, output_hidden_states=True, return_dict_in_generate=True)
```

Again, thanks for all your awesome work!