r""" encoder_hidden_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, sequence_length, hidden_size)`, `optional`): Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if the model is configured as a decoder
(
self,
input_ids=None,
attention_mask=None,
position_ids=None,
head_mask=None,
inputs_embeds=None,
encoder_embeds=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
past_key_values=None,
use_cache=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
is_decoder=False,
mode='multimodal',
)
| 743 | return extended_attention_mask |
| 744 | |
| 745 | def forward( |
| 746 | self, |
| 747 | input_ids=None, |
| 748 | attention_mask=None, |
| 749 | position_ids=None, |
| 750 | head_mask=None, |
| 751 | inputs_embeds=None, |
| 752 | encoder_embeds=None, |
| 753 | encoder_hidden_states=None, |
| 754 | encoder_attention_mask=None, |
| 755 | past_key_values=None, |
| 756 | use_cache=None, |
| 757 | output_attentions=None, |
| 758 | output_hidden_states=None, |
| 759 | return_dict=None, |
| 760 | is_decoder=False, |
| 761 | mode='multimodal', |
| 762 | ): |
| 763 | r""" |
| 764 | encoder_hidden_states (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, sequence_length, hidden_size)`, `optional`): |
| 765 | Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if |
| 766 | the model is configured as a decoder. |
| 767 | encoder_attention_mask (:obj:`torch.FloatTensor` of shape :obj:`(batch_size, sequence_length)`, `optional`): |
| 768 | Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in |
| 769 | the cross-attention if the model is configured as a decoder. Mask values selected in ``[0, 1]``: |
| 770 | - 1 for tokens that are **not masked**, |
| 771 | - 0 for tokens that are **masked**. |
| 772 | past_key_values (:obj:`tuple(tuple(torch.FloatTensor))` of length :obj:`config.n_layers` with each tuple having 4 tensors of shape :obj:`(batch_size, num_heads, sequence_length - 1, embed_size_per_head)`): |
| 773 | Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding. |
| 774 | If :obj:`past_key_values` are used, the user can optionally input only the last :obj:`decoder_input_ids` |
| 775 | (those that don't have their past key value states given to this model) of shape :obj:`(batch_size, 1)` |
| 776 | instead of all :obj:`decoder_input_ids` of shape :obj:`(batch_size, sequence_length)`. |
| 777 | use_cache (:obj:`bool`, `optional`): |
| 778 | If set to :obj:`True`, :obj:`past_key_values` key value states are returned and can be used to speed up |
| 779 | decoding (see :obj:`past_key_values`). |
| 780 | """ |
| 781 | output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions |
| 782 | output_hidden_states = ( |
| 783 | output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states |
| 784 | ) |
| 785 | return_dict = return_dict if return_dict is not None else self.config.use_return_dict |
| 786 | |
| 787 | if is_decoder: |
| 788 | use_cache = use_cache if use_cache is not None else self.config.use_cache |
| 789 | else: |
| 790 | use_cache = False |
| 791 | |
| 792 | if input_ids is not None and inputs_embeds is not None: |
| 793 | raise ValueError("You cannot specify both input_ids and inputs_embeds at the same time") |
| 794 | elif input_ids is not None: |
| 795 | input_shape = input_ids.size() |
| 796 | batch_size, seq_length = input_shape |
| 797 | device = input_ids.device |
| 798 | elif inputs_embeds is not None: |
| 799 | input_shape = inputs_embeds.size()[:-1] |
| 800 | batch_size, seq_length = input_shape |
| 801 | device = inputs_embeds.device |
| 802 | elif encoder_embeds is not None: |
nothing calls this directly
no test coverage detected