How to get cross attention for bert when config.add_cross_attention is True
# ❓ Questions & Help

<!-- The GitHub issue tracker is primarly intended for bugs, feature requests,
     new models and benchmarks, and migration questions. For all other questions,
     we direct you to the Hugging Face forum: https://discuss.huggingface.co/ .
     You can also try Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. In this case, make sure to tag your
     question with the right deep learning framework as well as the
     huggingface-transformers tag: 
     https://stackoverflow.com/questions/tagged/huggingface-transformers 
     -->

## Details
<!-- Description of your issue -->
As far as I can tell, when using BERT with cross attention and output_attention is True, the returned attention only contains self attention (i.e. a tuple of length num_hidden_layers with size (batch_size, num_head, seq_length, seq_length)). How can I get the cross attention weights in that case?

After digging a little bit, I saw that ModelOutput (and child classes) do not include cross attention as potential outputs. The cross attention is returned by [BertLayer](https://github.com/huggingface/transformers/blob/master/src/transformers/modeling_bert.py#L420) (at index 2) but then ignored in [BertEncoder](https://github.com/huggingface/transformers/blob/master/src/transformers/modeling_bert.py#L486). A quick look at the outputs for Encoder-Decoder models shows the same issue. Would it be possible to include cross attention in model outputs? And if yes, how can I help doing so?

<!-- You should first ask your question on the forum or SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to similar question on the forum/Stack Overflow**: https://discuss.huggingface.co/t/how-to-get-cross-attention-values-of-t5/970
Hey @qmeeus - thanks for your issue. This corresponds actually to a larger feature requests since we never return the attention masks at the moment. I will open a discussion about this internally and add it to the projects. <|||||>Hi @patrickvonplaten and thank you for your answer ! Let me know if I can help in any way with the developments<|||||>This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
<|||||>This should be resolved now. Bert2Bert can return cross attention masks with `output_attentions=True`