XGLM - Fix Softmax NaNs when using FP16
# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes #18049 following the exact same procedure used in #17437. Beside the added test, I also evaluated the fix on my personal use-case and found the behavior of the fixed model to be consistent when performing single or batched generation.


## Before submitting
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [x] Did you write any new necessary tests?


## Who can review?

@patil-suraj @ydshieh @patrickvonplaten 

_The documentation is not available anymore as the PR was closed or merged._<|||||>@patil-suraj I think only your check is missing!<|||||>Sorry for being so late here @gsarti! Merged master into it to ping circle ci here<|||||>Hey @gsarti - it seems like a test is failing now: 
```
tests/models/xglm/test_modeling_xglm.py::XGLMModelTest::test_xglm_model_past
```

with 

```
 UnboundLocalError: local variable 'dtype_attn_weights' referenced before assignment
```<|||||>> Hey @gsarti - it seems like a test is failing now:
> 
> ```
> tests/models/xglm/test_modeling_xglm.py::XGLMModelTest::test_xglm_model_past
> ```
> 
> with
> 
> ```
>  UnboundLocalError: local variable 'dtype_attn_weights' referenced before assignment
> ```

I noticed this when running the code. My understanding is that setting `dtype_attn_weights` as `torch.float32` as default beforehand would fix the issue and maintain the expected behavior, could you double-check?<|||||>Hi @gsarti Sorry for being late for this PR. I re-opened it and give some suggestion for a fix to the failing test. Would you like to update this PR after rebasing your working branch on an updated `main` branch?<|||||>Hi @gsarti I made the necessary change to pass the tests, and pushed to your branch directly. The remaining failing test is irrelevant to this PR, but I will wait until tomorrow to check again, then I will merge.

cc @patrickvonplaten and @younesbelkada <|||||>Thanks a lot for the fix @ydshieh !!
I think for consistency we should apply the same changes on OPT too, I will take care of that first thing in the morning tomorrow 💪 