add changes in mistral model to avoid problems in pytorch hooks
Author: peulsilva
Pull request: yes

# What does this PR do?

Removing keyword arguments to allow pytorch hooks.
As keyword arguments are not passed to pytorch hooks (`Module.register_forward_hook`), removing keywords in MistralDecoderLayer allows us to hook the intermediary steps of the attentio calculation. Does not change the behavior of any other methods

Here is an example

```
from transformers import AutoModelForCausalLM, AutoTokenizer

base_model = AutoModelForCausalLM.from_pretrained(
    "mistralai/Mistral-7B-v0.1",
    attn_implementation="eager",
)

tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-v0.1")

```

Creating a hook function. Since now the arguments are not passed as kwargs, pytorch hooks can identify them in the `input` variable

```
internal_parameters = []
def hook_internal_parameters(module, input, output):
        hidden_states = input[0]
        attention_mask = input[1]
        position_ids = input[2]
        past_key_value = input[3]
        cache_position = input[6]


        bsz, q_len, _ = hidden_states.size()

        query_states = module.q_proj(hidden_states)
        key_states = module.k_proj(hidden_states)
        value_states = module.v_proj(hidden_states)

        d = {
            "query": query_states,
            "key" : key_states,
            "value" : value_states
        }
        internal_parameters.append(d)
```

Setting hook in `self_attn` modules

```
for name, internal_module in bae_model.named_modules():
     if name.endswith("self_attn"):
          internal_module.register_forward_hook(hook_internal_parameters)
```

Hooking internal embeddings

```
text = "hello world"
tokens= tokenizer(text, return_tensors="pt")
with torch.no_grad():
    out = base_model(**tokens)

internal_parameters
```

Comments:
> Thanks ! In principle this looks good to have. Can you demonstrate in a small handy snippet how these changes fixes the issue you mentioned? You could use this model: https://huggingface.co/hf-internal-testing/Mixtral-tiny for instance Would it also makes sense to propagate these changes to other archs as well ?

Just added a quick usage example here. 
Yes, it would be good to have these changes in other model as well!

@muellerzr They shouldn't change much. That being said, the past few months have been very active in terms of adding and reworking things like the cache. In most cases, it would be the addition, rather than removal of arguments to signatures, they would very rarely change name unless it's making something align with standard library patterns. 

Our best defence is catching things with tests. 

Saying all this - changing this means that mistral would now deviate from all the other `self_attn` calls in decoder layers in the library and I'm not sure this custom use case justifies the change, which, as you point out makes our code more brittle. 

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.