Bert Generation misses **model_kwargs in prepare_inputs_for_generation()
### System Info

https://github.com/huggingface/transformers/blob/main/src/transformers/models/bert_generation/modeling_bert_generation.py#L989

This function should clearly return ```**model_kwargs``` but it is not. This results in passed args such as ```encoder_hidden_states``` not being used for generation. 

### Who can help?

@gante @ArthurZucker @younesbelkada

### Information

- [X] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

I used this model for image-captioning task, where the visual features should be used as ```encoder_hidden_states``` for the model.generate() method. The current implementation will simply neglect this input and generates the same texts for every image. Hope this information is sufficient to see why the current implementation is problematic. 

### Expected behavior

current implementation: 

    def prepare_inputs_for_generation(self, input_ids, past_key_values=None, attention_mask=None, **model_kwargs):
        input_shape = input_ids.shape
        # if model is used as a decoder in encoder-decoder model, the decoder attention mask is created on the fly
        if attention_mask is None:
            attention_mask = input_ids.new_ones(input_shape)

        # cut decoder_input_ids if past is used
        if past_key_values is not None:
            input_ids = input_ids[:, -1:]

        return {"input_ids": input_ids, "attention_mask": attention_mask, "past_key_values": past_key_values}


Correct implementation (simply change the last line):

    def prepare_inputs_for_generation(self, input_ids, past_key_values=None, attention_mask=None, **model_kwargs):
        input_shape = input_ids.shape
        # if model is used as a decoder in encoder-decoder model, the decoder attention mask is created on the fly
        if attention_mask is None:
            attention_mask = input_ids.new_ones(input_shape)

        # cut decoder_input_ids if past is used
        if past_key_values is not None:
            input_ids = input_ids[:, -1:]

        return {"input_ids": input_ids, "attention_mask": attention_mask, "past_key_values": past_key_values, **model_kwargs}
Hi @luyuzhe111 

Thank you for rasing the question!

The model of type `BertGeneration`, when we want to use `generation` along `encoder`'s output, it would be a (decoder) component in an encoder-decoder (here `class EncoderDecoderModel`).

The `generation` takes care to create the `encoder_outputs`
https://github.com/huggingface/transformers/blob/906afa1d5c6054a641cb6abb009cdec732a5a094/src/transformers/generation/utils.py#L1342-L1347

and `EncoderDecoderModel.prepare_inputs_for_generation` pass it to the underlying decoder model.
https://github.com/huggingface/transformers/blob/906afa1d5c6054a641cb6abb009cdec732a5a094/src/transformers/models/encoder_decoder/modeling_encoder_decoder.py#L668-L681

So everything work correctly  🤗 .

However, if you want to use that model without our `class EncoderDecoderModel` but you still want to pass `BertGenerationDecoder`, then you will have to modify the code on your own.