Fix opt softmax small nit
# What does this PR do?

- Following the PR #18057 we found out that the argument `dtype_attn_weights ` is not defined outside the condition `if attention_mask is not None:` which makes the modeling code prone to potential bugs. Also, the solution provided in #18057 is clearer so this PR addresses the same change to make the implementations consistent across models that suffers from the same Softmax issue. 

cc @ydshieh @sgugger 

Can also confirm slow tests pass!
_The documentation is not available anymore as the PR was closed or merged._