Check for Bool instead of Optionals
Hey guys, 

forgive me if this note is naive (I'm not a Python professional) but during debugging the code I got thrown off by this line:

```
            if return_dict_in_generate and output_scores:
                beam_indices = tuple((beam_indices[beam_idx[i]] + (beam_idx[i],) for i in range(len(beam_indices))))
```

https://github.com/huggingface/transformers/blame/3335724376319a0c453049d0cd883504f530ff52/src/transformers/generation/utils.py#L2976

It seems like you're simply checking whether `return_dict_in_generate` and `output_scores` are not `None` instead of checking the underlying `Bool`s. I assume this is intended, correct? I'm asking because I passed `False` for both values and was wondering why it would still run the `beam_indices = tuple...` line.
Hi @seboslaw, thanks for raising this issue. 

I don't believe the logic there is checking for `None` values. In [L2850](https://github.com/huggingface/transformers/blame/3335724376319a0c453049d0cd883504f530ff52/src/transformers/generation/utils.py#L2850), `return_dict_in_generate` is set to either the bool value passed in, or defaults to the bool value in the config if unset / is None. The same happens to `output_scores` in [L2843](https://github.com/huggingface/transformers/blame/3335724376319a0c453049d0cd883504f530ff52/src/transformers/generation/utils.py#LL2843C18-L2843C18). 

However, even if it's less clear than an explicit `None` check e.g. `if x is None`, the `beam_indices` logic should only ever be executed if both `return_dict_in_generate` and `output_scores` both evaluate to `True` e.g. the following will only print out `True, True`. 

```
for a, b in (
    (None, None), (None, False), (False, None), (True, None), (None, True), (True, False), (False, True), (True, True)
):
    if a and b:
        print(a, b)
```

i.e. if the `beam_indices` line is still executing when both values are being set to `False` there's a probably a bug somewhere. Could you follow the issue template and provide details such that we can help debug this? Specifically:

* The running environment: run `transformers-cli env` in the terminal and copy-paste the output
* A minimal reproducible code snippet we can copy and run to replicate the issue? <|||||>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.