Fix stuff related to the causal_mask in CodeGen.
1. Line 613, `_keys_to_ignore_on_load_missing  =  [r"h\.\d+\.attn\.masked_bias", r"h\.\d+\.attn\.bias"]` => `_keys_to_ignore_on_load_missing  =  [r"h\.\d+\.attn\.causal_mask"]` to load correctly from CodeGen checkpoint without `causal_mask`.
2. Line 152, `causal_mask = self.causal_mask[:, :, key_length - query_length : key_length, :key_length]
` => `causal_mask = self.causal_mask[:, :, key_length - query_length : key_length, :key_length].bool()
` to alleviate potential user warning saying like `UserWarning: where received a uint8 condition tensor. This behavior is deprecated and will be removed in a future version of PyTorch. Use a boolean condition instead.`.

# 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 # (issue)


## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] 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.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts and @NielsRogge
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @sgugger

Integrations:

- deepspeed: HF Trainer: @stas00, Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam

Documentation: @sgugger, @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: @sgugger
- TensorFlow: @Rocketknight1

 -->

_The documentation is not available anymore as the PR was closed or merged._<|||||>cc @ArthurZucker and @younesbelkada <|||||>Following up on my comment, here is a script I ran: 

```python

import torch
import torch.nn as nn

class DummyModelUint(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(10, 10)
        self.register_buffer("attention_mask", torch.ones(10, 10, dtype=torch.uint8))

    def forward(self, x):
        return self.linear(x)

class DummyModelBool(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(10, 10)
        self.register_buffer("attention_mask", torch.ones(10, 10, dtype=torch.bool))

    def forward(self, x):
        return self.linear(x)

model_uint8 = DummyModelUint()
state_dict = model_uint8.state_dict()

model_bool = DummyModelBool()
model_bool.load_state_dict(state_dict)

print(model_bool.attention_mask.dtype)
>>> torch.bool
```
So even if you save `uint8` buffers on the state dict, if you load it through a model that has `torch.bool` buffer it will overwrite it in `torch.bool`. So I don't think the first fix is needed if we merge #21384 ! 
However your second fix might make sense, just need more clarification ;) <|||||>@younesbelkada 
Thanks for your review.

1. Removing `[r"h\.\d+\.attn\.masked_bias", r"h\.\d+\.attn\.bias"]` basically due to there are not `masked_bias` or `bias` in `attn`. I conjecture the reason why they leave these two terms here is that they copy part of the code from GPTJ (https://github.com/huggingface/transformers/blob/main/src/transformers/models/gptj/modeling_gptj.py#L723).
2. Introducing `.bool()` due to it will raise a warning when later execute the `torch.where` (https://github.com/huggingface/transformers/blob/main/src/transformers/models/codegen/modeling_codegen.py#L165). However, it seems that this will be addressed in another PR.
<|||||>2. The causal mask should not be a `bool` no?  I might not be looking at the correct line in the code, but the only bool is going the be the attention mask that we feed the network, which is then used to created the causal mask by multiplying with `torch.finfo(...).min`. (so something like -1e-9)<|||||>I agree that we should leave the fix 2 to PR https://github.com/huggingface/transformers/pull/21384.