GPT2Model cannot handle 3D attention_mask
When pretraining GPT2 model, it sometimes need to receive a 3d attention_mask. Let's take an example with "gpt2" model. The model would be trained with an instance consisting of two different document "I am a boy. <|endoftext|> you are rich.".
tokenizer convert the sentence into input_ids: [40, 716, 257, 2933, 13, 220, 50256, 345, 389, 5527, 13] and attention_mask: [1,1,1,1,1,1,1,1,1,1,1].
Since "I am a boy." and "you are rich." are from different documents, when predicting "you are rich." we do not want GPT to attend "I am a boy.", leading to the need for 3d attention_mask. Other models like BERT can handle this problem with the function "get_extended_attention_mask" from modeling_utils.

However, GPT2 model considers only 2d attention_mask now.
https://github.com/huggingface/transformers/blob/2e5dbdf2db4599a6694d0974575a70f9bc3c978e/src/transformers/models/gpt2/modeling_gpt2.py#L697


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/master/CONTRIBUTING.md) are likely to be ignored.