From the documentation I see that model will accept 1D tensor (assume batch size equal 1) but what I need is 2D attention mask. How can I manage to do that? Thanks for your response.
attention_mask ( torch.FloatTensor of shape ((batch_size, sequence_length)) , optional) –
Mask to avoid performing attention on padding token indices. Mask values selected in [0, 1] :

1 for tokens that are not masked ,
0 for tokens that are masked .