Documentation error in Trainer.predict when output_hidden_states is True
Author: cbrew
Pull request: no

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.17.0.dev0
- Platform: macOS-11.4-x86_64-i386-64bit
- Python version: 3.9.8
- PyTorch version (GPU?): 1.10.2 (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

@sgugger


## Information

Model I am using (Bert, XLNet ...): sentence-transformers/all-mpnet-base-v3

The problem arises when using:
* [*] my own modified scripts: (give details below)

The tasks I am working on is:
* [*] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

1. Run script below, which is standard Trainer loop, except that model has `output_hidden_states == True`.

```
import numpy as np
import transformers
from transformers import (
    AutoTokenizer,
    AutoModelForSequenceClassification,
    DataCollatorWithPadding,
    TrainingArguments,
    Trainer,
)
from datasets import load_dataset

dataset_name = "banking77"
data = load_dataset(dataset_name)

names = data["train"].features["label"].names

model_name = "sentence-transformers/all-mpnet-base-v2"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(
    model_name, output_hidden_states=True, num_labels=len(names)
)


def preprocess_function(examples):
    return tokenizer(examples["text"], truncation=True)


tokenized_data = data.map(preprocess_function, batched=True)

data_collator = DataCollatorWithPadding(tokenizer=tokenizer)


training_args = TrainingArguments(
    output_dir="./results",
    learning_rate=2e-5,
    per_device_train_batch_size=16,
    per_device_eval_batch_size=16,
    num_train_epochs=5,
    weight_decay=0.01,
)

trainer = Trainer(
    model=model,
    args=training_args,
    train_dataset=tokenized_data["train"],
    eval_dataset=tokenized_data["test"],
    tokenizer=tokenizer,
    data_collator=data_collator,
)
# slow on CPU, but never mind
trainer.train()

#
predictions = trainer.predict(tokenized_data["test"])


assert isinstance(predictions, transformers.trainer_utils.PredictionOutput)
assert isinstance(predictions.predictions, tuple)
assert isinstance(predictions.label_ids, np.ndarray)
assert isinstance(predictions.metrics, dict)
logits = predictions.predictions[0]
assert isinstance(logits, np.ndarray)
hidden_states = predictions.predictions[1]
assert isinstance(hidden_states, tuple)

```


## Expected behavior

Runs without incident, shows that when we have `output_hidden_states=True`, predictions.predictions is a `tuple`, not an `ndarray`. Documentation of Trainer.predict currently says result will be ndarray, but it isn't, so documentation of Trainer.predict
should finish with:

     ```
     Returns: *NamedTuple* A namedtuple with the following keys:

            - predictions (Union[`np.ndarray`,`Tuple`]): The predictions on `test_dataset`. Will be np.ndarray if
            `output_hidden_states` is `False`, or 2-element tuple if `output_hidden_states` is `True`.
            - label_ids (`np.ndarray`, *optional*): The labels (if the dataset contained some).
            - metrics (`Dict[str, float]`, *optional*): The potential dictionary of metrics (if the dataset contained
              labels).
    ```



Comments:
pull request #15743 provides the suggested documentation change.

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.