HubertModel output wrong `last_hidden_state` shape.
Author: celsofranssa
Pull request: no

### System Info

- `transformers` version: 4.26.0
- Platform: Linux-5.10.147+-x86_64-with-glibc2.29
- Python version: 3.8.10
- Huggingface_hub version: 0.12.0
- PyTorch version (GPU?): 1.13.1+cu116 (False)
- Tensorflow version (GPU?): 2.9.2 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed

### Who can help?

@sanchit-gandhi

### Information

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

### Tasks

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

### Reproduction

As stated in [HuBERTModel docs](https://huggingface.co/docs/transformers/model_doc/hubert#transformers.HubertModel), `last_hidden_state` shape should be `(batch_size, sequence_length, hidden_size)`.

```python
from transformers import AutoProcessor, HubertModel
from datasets import load_dataset
import soundfile as sf

processor = AutoProcessor.from_pretrained("facebook/hubert-large-ls960-ft")
model = HubertModel.from_pretrained("facebook/hubert-large-ls960-ft")

input_values = torch.rand(16,4096) # sequence_length = 4096
input_values.shape

last_hidden_state = model(input_values).last_hidden_state
last_hidden_state.shape
```
However, the shape of  `last_hidden_state` was `torch.Size([16, 12, 1024])`.

### Expected behavior

The shape of  `last_hidden_state`  should be  `torch.Size([16, 4096, 1024])`.

Comments:
Hey @celsofranssa! Really great question! In the HuBERT model, we take an input sequence of raw audio waveforms, _downsample_ them using a series of 1d-convolutional networks, and pass the downsampled hidden-states to a Transformer network.

In this case, `sequence_length` is referring to the downsampled sequence length (i.e. the sequence length _after_ we apply the 1-d convolutional networks). This is equal to the final sequence length of the HuBERT model (since there's no further downsampling by the Transformer network).

We can verify this with the `_get_feat_extract_output_length` method, which computes the downsampled sequence length of the HuBERT model:
https://github.com/huggingface/transformers/blob/21a2d900eceeded7be9edc445b56877b95eda4ca/src/transformers/models/hubert/modeling_hubert.py#L867

Using this method, we get:
```python
from transformers import AutoProcessor, HubertModel
from datasets import load_dataset
import torch

processor = AutoProcessor.from_pretrained("facebook/hubert-large-ls960-ft")
model = HubertModel.from_pretrained("facebook/hubert-large-ls960-ft")

input_values = torch.rand(16,4096) # sequence_length = 4096
print("Input shape: ", input_values.shape)

with torch.no_grad():
    last_hidden_state = model(input_values).last_hidden_state
print("Last hidden dim: ", last_hidden_state.shape)

sequence_len = model._get_feat_extract_output_lengths(input_lengths=input_values.shape[-1])
print("seq len: ", sequence_len)

print("Shapes match? ", sequence_len == last_hidden_state.shape[1])
```
**Print Output:**
```
Input shape:  torch.Size([16, 4096])
Last hidden dim:  torch.Size([16, 12, 1024])
seq len:  tensor(12)
Shapes match?  tensor(True)
```

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