+
    œ°³jhS ã                   óÐ  € R t ^ RIt^ RIt^ RIHt ^ RIt^ RIHtHt ^ RIH	t	 ^RI
Ht ^RIHtHtHt ^RIHt ^RIHt ^R	IHt ^R
IHt ^RIHtHtHtHt ^RIHt ]P>                  ! ] 4      t!R;R lt"R t#R;R lt$R t%]! RR7      ] ! R R]4      4       4       t&]! RR7      ] ! R R]4      4       4       t']! RR7      ] ! R R]4      4       4       t(]! RR7      ] ! R R]4      4       4       t)] ! R R]4      4       t* ! R R ]PV                  4      t, ! R! R"]PZ                  4      t. ! R# R$]PZ                  4      t/ ! R% R&]PZ                  4      t0 ! R' R(]4      t1 ! R) R*]4      t2]! R+R7       ! R, R-]*4      4       t3]! R.R7       ! R/ R0]*4      4       t4] ! R1 R2]*4      4       t5]! R3R7       ! R4 R5]*]4      4       t6]! R6R7       ! R7 R8]*]4      4       t7 ! R9 R:]*4      t8. R<Ot9R# )=zRPyTorch ProphetNet model, ported from ProphetNet repo(fairsequery_states version).N)Ú	dataclass)ÚTensorÚnn)Ú	LayerNorm)ÚACT2FN)ÚCacheÚDynamicCacheÚEncoderDecoderCache)ÚGenerationMixin)ÚGradientCheckpointingLayer)ÚBaseModelOutput)ÚPreTrainedModel)ÚModelOutputÚauto_docstringÚloggingÚtorch_compilable_check©ÚProphetNetConfigc                 óÎ   € V'       d0   \         P                  P                  V P                  4       VR 7      # \         P                  P                  W\        P
                  R7      # )©Údim©r   Údtype)r   Ú
functionalÚsoftmaxÚfloatÚtorchÚfloat32)Úhidden_stater   Ú
onnx_traces   &&&Ús/home/luca/screen-checking/.venv/lib/python3.14/site-packages/transformers/models/prophetnet/modeling_prophetnet.pyr   r   %   sF   € ßÜ�}‰}×$Ñ$ \×%7Ñ%7Ó%9¸sÐ$ÓCÐCä�}‰}×$Ñ$ \Ä%Ç-Á-Ð$ÓPÐPó    c                ó„  € \         P                  ! V4      P                  p\         P                  ! WR7      P	                  ^V ^4      p\         P                  ! WR7      P	                  ^^V 4      p\         P                  ! WR7      ) ^,           P	                  V^^4      pWe,
          V8¬  V^ 8g  ,          pWV8g  P                  WV 4      p	\         P                  ! RWCVR7      p
\         P                  ! RW2R7      p\         P                  ! WŠV4      p\         P                  ! WšV4      p\         P                  ! WÍ.^R7      # )z8
This function computes the bias for the predict stream
)Údevice©r   r#   r   © )
r   ÚfinfoÚminÚarangeÚviewÚexpandÚfullÚzerosÚwhereÚcat)Úsequence_lengthÚngramr#   r   Úneg_infÚrowsÚcolsÚstream_offsetsÚ	left_maskÚ
right_maskÚ	neg_inf_tÚzero_tÚ
left_blockÚright_blocks   &&&&          r    Úngram_attention_biasr;   ,   sù   € ô �kŠk˜%Ó ×$Ñ$€GÜ�<Š<˜Ô7×<Ñ<¸QÀÐQRÓS€DÜ�<Š<˜Ô7×<Ñ<¸QÀÀ?ÓS€DÜ—|’| EÔ9Ð9¸AÕ=×CÑCÀEÈ1ÈaÓP€Nð • Ñ.°4¸1±9Õ=€Ià‘,×&Ñ& u¸ÓO€Jä—
’
˜2˜w¸FÔC€IÜ�[Š[˜ 5Ô8€FÜ—’˜Y°6Ó:€JÜ—+’+˜j°VÓ<€KÜ�9Š9�jÐ.°AÔ6Ð6r!   c                ó(  € V) p^ pV'       dh   V ^,          p V\         P                  ! V\         P                  ! V4      4      P                  4       V ,          ,           p\         P                  ! V4      pM+\         P
                  ! V\         P                  ! V4      4      pV ^,          p\         P                  ! WF4      pV\         P                  ! VP                  4       V,          4      \        P                  ! W,          4      ,          W,
          ,          ,           p\         P                  ! V\         P                  ! V4      V ^,
          ,          4      P                  4       pV\         P                  ! WtP                  4       V4      ,           pV# )zg
This function computes individual parts of the relative position buckets. For more detail, see paper.
)r   ÚltÚ
zeros_likeÚintÚabsÚmaxÚlogr   Úmathr'   Ú	ones_liker-   )	Únum_bucketsÚmax_distanceÚrelative_positionsÚis_bidirectionalÚinv_relative_positionsÚrel_positions_bucketÚ	max_exactÚis_smallÚval_if_larges	   &&&&     r    Úcompute_relative_bucketsrN   B   s>  € ð 1Ð0ÐØÐçØ! QÕ&ˆà Ü�hŠhÐ-¬u×/?Ò/?Ð@VÓ/WÓX×\Ñ\Ó^ÐalÕlõmð 	ô "'§¢Ð+AÓ!BÑä!&§¢Ð+AÄ5×CSÒCSÐTjÓCkÓ!lÐà˜qÕ €IÜ�xŠxÐ.Ó:€HØœuŸyšyÐ)?×)EÑ)EÓ)GÈ)Õ)SÓTÔW[×W_ÒW_ØÕ óXõ  à	Õ	 õ "õ "€Lô —9’9˜\¬5¯?ª?¸<Ó+HÈKÐZ[ÍOÕ+\Ó]×aÑaÓc€LØ/´%·+²+¸h×HbÑHbÓHdÐfrÓ2sÕsÐØÐr!   c                ó¢  € VP                  ^4      P                  ^VP                  R4      ^4      pW2P                  R4      ,
          p\        P                  ! V^,
          V3RR7      P                  ^4      pVP                  ^VP                  R4      ^4      pWBP                  R4      ,
          p\        WVRR7      p\        WVRR7      pWV3# )ze
This function computes both main and predict relative position buckets. For more detail, see paper.
r   F)rH   éÿÿÿÿ)Ú	unsqueezeÚrepeatÚsizer   r.   rN   )rE   rF   Úposition_idsÚmain_stream_relative_positionsÚ$predicting_stream_relative_positionsÚmain_relative_position_bucketsÚ!predict_relative_position_bucketss   &&&    r    Ú#compute_all_stream_relative_bucketsrY   ]   sá   € ð
 &2×%;Ñ%;¸AÓ%>×%EÑ%EÀaÈ×IZÑIZÐ[]ÓI^Ð`aÓ%bÐ"Ø%C×F\ÑF\Ð]_ÓF`Õ%`Ð"ô ,1¯9ª9°lÀQÕ6FÈÐ5UÐ[]Ô+^×+hÑ+hÐijÓ+kÐ(Ø+O×+VÑ+VÐWXÐZf×ZkÑZkÐlnÓZoÐqrÓ+sÐ(Ø+O×RhÑRhÐikÓRlÕ+lÐ(ô &>ØÐ#AÐTYô&Ð"ô )AØÐ#GÐZ_ô)Ð%ð *ÐLÐLr!   zF
    Base class for sequence-to-sequence language models outputs.
    )Úcustom_introc                   ó`   a € ] tR t^tt o RtRtRtRtRtRt	Rt
RtRtRtRtRtRtV 3R ltRtV tR# )ÚProphetNetSeq2SeqLMOutputar  
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
    Language modeling loss.
logits (`torch.FloatTensor` of shape `(batch_size, decoder_sequence_length, config.vocab_size)`):
    Prediction scores of the main stream language modeling head (scores for each vocabulary token before
    SoftMax).
logits_ngram (`torch.FloatTensor` of shape `(batch_size, ngram * decoder_sequence_length, config.vocab_size)`):
    Prediction scores of the predict stream language modeling head (scores for each vocabulary token before
    SoftMax).
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
    It is a [`~cache_utils.Cache`] instance. For more details, see our [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache).

    Contains pre-computed hidden-states (key and values in the attention blocks) of the decoder that can be
    used (see `past_key_values` input) to speed up sequential decoding.
decoder_ngram_hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
    Tuple of `torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer) of
    shape `(batch_size, ngram * decoder_sequence_length, hidden_size)`.

    Hidden-states of the predict stream of the decoder at the output of each layer plus the initial embedding
    outputs.
decoder_ngram_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
    Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_attn_heads,
    decoder_sequence_length, decoder_sequence_length)`.

    Attentions weights of the predict stream of the decoder, after the attention softmax, used to compute the
    weighted average in the self-attention heads.
encoder_last_hidden_state (`torch.FloatTensor` of shape `(batch_size, encoder_sequence_length, hidden_size)`, *optional*):
    Sequence of hidden-states at the output of the last layer of the encoder of the model.
Nc                óž  <€ V ^8„  d   Qh/ S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R	&   S[S[ P                  ,          R,          ;R
&   S[ P                  R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   # )é   NÚlossÚlogitsÚlogits_ngramÚpast_key_valuesÚdecoder_hidden_statesÚdecoder_ngram_hidden_statesÚdecoder_attentionsÚdecoder_ngram_attentionsÚcross_attentionsÚencoder_last_hidden_stateÚencoder_hidden_statesÚencoder_attentions©r   ÚFloatTensorr   Útuple)ÚformatÚ__classdict__s   "€r    Ú__annotate__Ú&ProphetNetSeq2SeqLMOutput.__annotate__t   sY  ø‡ ‚ ñJ ×
Ñ
˜dÕ
"Ñ)ñK ñL ×Ñ Õ$Ñ+ñM ñN ×#Ñ# dÕ*Ñ1ñO ñP ˜T•\Ñ(ñQ ñR !¡×!2Ñ!2Õ3°dÕ:ÑAñS ñT "'¡u×'8Ñ'8Õ!9¸DÕ!@ÑGñU ñV ™e×/Ñ/Õ0°4Õ7Ñ>ñW ñX $¡E×$5Ñ$5Õ6¸Õ=ÑDñY ñZ ™E×-Ñ-Õ.°Õ5Ñ<ñ[ ñ\  %×0Ñ0°4Õ7Ñ>ñ] ñ^ !¡×!2Ñ!2Õ3°dÕ:ÑAñ_ ñ` ™e×/Ñ/Õ0°4Õ7Ñ>òa r!   r%   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©ro   s   @r    r\   r\   t   sX   ø‡ € ñð< &*€DØ'+€FØ-1€LØ$(€OØ=AÐØCGÐØ:>ÐØ@DÐØ8<ÐØ:>ÐØ=AÐØ:>Ð÷a ƒ r!   r\   z‹
    Base class for model encoder's outputs that also contains : pre-computed hidden states that can speed up sequential
    decoding.
    c                   óX   a € ] tR t^§t o RtRtRtRtRtRt	Rt
RtRtRtRtV 3R ltRtV tR# )ÚProphetNetSeq2SeqModelOutputad  
last_hidden_state (`torch.FloatTensor` of shape `(batch_size, decoder_sequence_length, hidden_size)`):
    Sequence of main stream hidden-states at the output of the last layer of the decoder of the model.

    If `past_key_values` is used only the last hidden-state of the sequences of shape `(batch_size, 1,
    hidden_size)` is output.
last_hidden_state_ngram (`torch.FloatTensor` of shape `(batch_size,ngram * decoder_sequence_length, config.vocab_size)`, *optional*):
    Sequence of predict stream hidden-states at the output of the last layer of the decoder of the model.
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
    It is a [`~cache_utils.Cache`] instance. For more details, see our [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache).

    Contains pre-computed hidden-states (key and values in the attention blocks) of the decoder that can be
    used (see `past_key_values` input) to speed up sequential decoding.
decoder_ngram_hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
    Tuple of `torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer) of
    shape `(batch_size, ngram * decoder_sequence_length, hidden_size)`.

    Hidden-states of the predict stream of the decoder at the output of each layer plus the initial embedding
    outputs.
decoder_ngram_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
    Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_attn_heads,
    decoder_sequence_length, decoder_sequence_length)`.

    Attentions weights of the predict stream of the decoder, after the attention softmax, used to compute the
    weighted average in the
encoder_last_hidden_state (`torch.FloatTensor` of shape `(batch_size, encoder_sequence_length, hidden_size)`, *optional*):
    Sequence of hidden-states at the output of the last layer of the encoder of the model.
Nc                ób  <€ V ^8„  d   Qh/ S[ P                  ;R&   S[ P                  R,          ;R&   S[R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R	&   S[ P                  R,          ;R
&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   # )r^   Úlast_hidden_stateNÚlast_hidden_state_ngramrb   rc   rd   re   rf   rg   rh   ri   rj   rk   )rn   ro   s   "€r    rp   Ú)ProphetNetSeq2SeqModelOutput.__annotate__§   s:  ø‡ ‚ ñJ ×(Ñ(Ñ(ñK ñL #×.Ñ.°Õ5Ñ<ñM ñN ˜T•\Ñ(ñO ñP !¡×!2Ñ!2Õ3°dÕ:ÑAñQ ñR "'¡u×'8Ñ'8Õ!9¸DÕ!@ÑGñS ñT ™e×/Ñ/Õ0°4Õ7Ñ>ñU ñV $¡E×$5Ñ$5Õ6¸Õ=ÑDñW ñX ™E×-Ñ-Õ.°Õ5Ñ<ñY ñZ  %×0Ñ0°4Õ7Ñ>ñ[ ñ\ !¡×!2Ñ!2Õ3°dÕ:ÑAñ] ñ^ ™e×/Ñ/Õ0°4Õ7Ñ>ò_ r!   r%   )rr   rs   rt   ru   rv   r   rb   rc   rd   re   rf   rg   rh   ri   rj   rw   rx   ry   rz   s   @r    r|   r|   §   sO   ø‡ € ñð< 9=ÐØ$(€OØ=AÐØCGÐØ:>ÐØ@DÐØ8<ÐØ:>ÐØ=AÐØ:>Ð÷_ ƒ r!   r|   zs
    Base class for model's outputs that may also contain a past key/values (to speed up sequential decoding).
    c                   óL   a € ] tR t^Ùt o RtRtRtRtRtRt	Rt
RtV 3R ltRtV tR# )ÚProphetNetDecoderModelOutputas  
last_hidden_state (`torch.FloatTensor` of shape `(batch_size, decoder_sequence_length, hidden_size)`):
    Sequence of main stream hidden-states at the output of the last layer of the decoder of the model.

    If `past_key_values` is used only the last hidden-state of the sequences of shape `(batch_size, 1,
    hidden_size)` is output.
last_hidden_state_ngram (`torch.FloatTensor` of shape `(batch_size, ngram * decoder_sequence_length, config.vocab_size)`):
    Sequence of predict stream hidden-states at the output of the last layer of the decoder of the model.
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
    It is a [`~cache_utils.Cache`] instance. For more details, see our [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache).

    Contains pre-computed hidden-states (key and values in the attention blocks) of the decoder that can be
    used (see `past_key_values` input) to speed up sequential decoding.
hidden_states_ngram (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
    Tuple of `torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer) of
    shape `(batch_size, ngram * decoder_sequence_length, hidden_size)`.

    Hidden-states of the predict stream of the decoder at the output of each layer plus the initial embedding
    outputs.
ngram_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
    Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_attn_heads,
    decoder_sequence_length, decoder_sequence_length)`.

    Attentions weights of the predict stream of the decoder, after the attention softmax, used to compute the
    weighted average in the
Nc                ó¸  <€ V ^8„  d   Qh/ S[ P                  ;R&   S[ P                  R,          ;R&   S[R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R	&   # )
r^   r~   Nr   rb   Úhidden_statesÚhidden_states_ngramÚ
attentionsÚngram_attentionsrg   rk   )rn   ro   s   "€r    rp   Ú)ProphetNetDecoderModelOutput.__annotate__Ù   sâ   ø‡ ‚ ñD ×(Ñ(Ñ(ñE ñF #×.Ñ.°Õ5Ñ<ñG ñH ˜T•\Ñ(ñI ñJ ™×*Ñ*Õ+¨dÕ2Ñ9ñK ñL ™u×0Ñ0Õ1°DÕ8Ñ?ñM ñN ‘e×'Ñ'Õ(¨4Õ/Ñ6ñO ñP ™E×-Ñ-Õ.°Õ5Ñ<ñQ ñR ™E×-Ñ-Õ.°Õ5Ñ<òS r!   r%   )rr   rs   rt   ru   rv   r   rb   r„   r…   r†   r‡   rg   rw   rx   ry   rz   s   @r    r‚   r‚   Ù   s;   ø‡ € ñð8 9=ÐØ$(€OØ59€MØ;?ÐØ26€JØ8<ÐØ8<Ð÷S ƒ r!   r‚   c                   óT   a € ] tR tRt o RtRtRtRtRtRt	Rt
RtRtRtV 3R ltRtV tR# )ÚProphetNetDecoderLMOutputi  aF	  
ngram_hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
    Tuple of `torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer) of
    shape `(batch_size, ngram * decoder_sequence_length, hidden_size)`.

    Hidden-states of the predict stream of the decoder at the output of each layer plus the initial embedding
    outputs.
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
    Language modeling loss.
logits (`torch.FloatTensor` of shape `(batch_size, decoder_sequence_length, config.vocab_size)`):
    Prediction scores of the main stream language modeling head (scores for each vocabulary token before
    SoftMax).
logits_ngram (`torch.FloatTensor` of shape `(batch_size, ngram * decoder_sequence_length, config.vocab_size)`):
    Prediction scores of the predict stream language modeling head (scores for each vocabulary token before
    SoftMax).
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
    It is a [`~cache_utils.Cache`] instance. For more details, see our [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache).

    Contains pre-computed hidden-states (key and values in the attention blocks) of the decoder that can be
    used (see `past_key_values` input) to speed up sequential decoding.
hidden_states_ngram (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
    Tuple of `torch.FloatTensor` (one for the output of the embeddings + one for the output of each layer) of
    shape `(batch_size, ngram * decoder_sequence_length, hidden_size)`.

    Hidden-states of the predict stream of the decoder at the output of each layer plus the initial embedding
    outputs.
ngram_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
    Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_attn_heads,
    decoder_sequence_length, decoder_sequence_length)`.

    Attentions weights of the predict stream of the decoder, after the attention softmax, used to compute the
    weighted average in the
Nc                óô  <€ V ^8„  d   Qh/ S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[ P                  R,          ;R&   S[R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R&   S[S[ P                  ,          R,          ;R	&   S[S[ P                  ,          R,          ;R
&   # )r^   Nr_   r`   ra   rb   r„   r…   r†   r‡   rg   rk   )rn   ro   s   "€r    rp   Ú&ProphetNetDecoderLMOutput.__annotate__  s  ø‡ ‚ ñR ×
Ñ
˜dÕ
"Ñ)ñS ñT ×Ñ Õ$Ñ+ñU ñV ×#Ñ# dÕ*Ñ1ñW ñX ˜T•\Ñ(ñY ñZ ™×*Ñ*Õ+¨dÕ2Ñ9ñ[ ñ\ ™u×0Ñ0Õ1°DÕ8Ñ?ñ] ñ^ ‘e×'Ñ'Õ(¨4Õ/Ñ6ñ_ ñ` ™E×-Ñ-Õ.°Õ5Ñ<ña ñb ™E×-Ñ-Õ.°Õ5Ñ<òc r!   r%   )rr   rs   rt   ru   rv   r_   r`   ra   rb   r„   r…   r†   r‡   rg   rw   rx   ry   rz   s   @r    rŠ   rŠ     sE   ø‡ € ñ ðD &*€DØ'+€FØ-1€LØ$(€OØ59€MØ;?ÐØ26€JØ8<ÐØ8<Ð÷c ƒ r!   rŠ   c                   ó:   a € ] tR tRt o RtRtR tV 3R ltRtV t	R# )ÚProphetNetPreTrainedModeli9  Ú
prophetnetTc                ó–  € V P                   P                  pV P                   P                  pVf   Q R4       hVP                  VP                  4      pVRR R13,          P                  4       VR&   W$R&   Vf   Q R4       hVP                  VR8H  V4       \        P                  ! V^ 8¬  4      P                  4       '       g   Q R4       hV# )	Nz™self.model.config.decoder_start_token_id has to be defined. In ProphetNet it is usually set to the pad_token_id. See ProphetNet docs for more information.z1self.model.config.pad_token_id has to be defined.z8Verify that `shifted_input_ids` has only positive valuesrP   ).ºé   NN).é    éœÿÿÿ)
ÚconfigÚdecoder_start_token_idÚpad_token_idÚ	new_zerosÚshapeÚcloneÚmasked_fill_r   ÚallÚitem)ÚselfÚ	input_idsr–   r—   Úshifted_input_idss   &&   r    Ú_shift_rightÚ&ProphetNetPreTrainedModel._shift_right?  sÒ   € Ø!%§¡×!CÑ!CÐØ—{‘{×/Ñ/ˆà%Ò1ð 	
ðFó	
Ð1ð &×/Ñ/°	·±Ó@ÐØ%.¨s°C°R°C¨xÕ%8×%>Ñ%>Ó%@Ð˜'Ñ"Ø$:˜&Ñ!àÒ'Ð\Ð)\Ó\Ð'à×&Ñ&Ð'8¸DÑ'@À,ÔOä�yŠyÐ*¨aÑ/Ó0×5Ñ5×7Ò7ÐsÐ9sÓsÐ7à Ð r!   c                ó&   <€ V ^8„  d   Qh/ S[ ;R&   # ©r^   r•   r   )rn   ro   s   "€r    rp   Ú&ProphetNetPreTrainedModel.__annotate__9  s   ø‡ ‚ áÑò r!   r%   N)
rr   rs   rt   ru   Úbase_model_prefixÚsupports_gradient_checkpointingr¡   rw   rx   ry   rz   s   @r    rŽ   rŽ   9  s   ø‡ € ð %ÐØ&*Ð#ò!÷ ƒ r!   rŽ   c                   ó^   a a€ ] tR tRt oRtV3R lV 3R lltRV 3R lltV 3R ltRtVt	V ;t
# )	ÚProphetNetPositionalEmbeddingsiV  zý
This module learns positional embeddings up to a fixed maximum size. Padding ids are ignored by either offsetting
based on padding_idx or by setting padding_idx to None and ensuring that the appropriate position ids are passed to
the forward function.
c                ó$   <€ V ^8„  d   QhRS[ RR/# )r^   r•   ÚreturnNr   )rn   ro   s   "€r    rp   Ú+ProphetNetPositionalEmbeddings.__annotate__]  s    ø€ ÷ bñ bÑ/ð b°Dñ br!   c                óˆ   <€ VP                   V n        \        SV `  VP                   VP                  VP
                  4       R # ©N)Úmax_position_embeddingsÚ
max_lengthÚsuperÚ__init__Úhidden_sizer—   ©rž   r•   Ú	__class__s   &&€r    r²   Ú'ProphetNetPositionalEmbeddings.__init__]  s3   ø€ Ø ×8Ñ8ˆŒÜ‰Ñ˜×7Ñ7¸×9KÑ9KÈV×M`ÑM`Öar!   c                óœ  <€ Ve   V P                   e   Q R4       hVEf   Ve   VP                  4       ^ 8w  dj   VP                  4       pV^,          V,           p\        P                  ! R\        P                  VR7      \        V P                   V,           4      ,          pM›Vf(   \        P                  ! V\        P                  VR7      p\        P                  ! V^R7      P                  V4      V,          P	                  4       V P                   ,           pVP                  ^ V P                  ^,
          4      p\        SV `-  V4      V3# )NzCIf position_ids is pre-computed then padding_idx should not be set.r$   r   )r’   r’   )Úpadding_idxÚget_seq_lengthr   ÚonesÚlongr?   ÚcumsumÚtype_asÚclampr°   r±   Úforward)	rž   Úinputs_shaper#   Úattention_maskrb   rT   Úprev_num_input_idsÚnum_input_idsrµ   s	   &&&&&&  €r    r¿   Ú&ProphetNetPositionalEmbeddings.forwarda  s  ø€ ØÒ$¨$×*:Ñ*:Ò*Bð 	
ØQó	
ÐCð ÓØÒ*¨×/MÑ/MÓ/OÐSTÔ/Tð &5×%CÑ%CÓ%EÐ"Ø ,¨Q¥Ð2DÕ D�Ü$Ÿzšz¨&¼¿
¹
È6ÔRÜ˜×(Ñ(¨=Õ8Ó9õ ‘ð "Ò)Ü%*§Z¢Z°ÄEÇJÁJÐW]Ô%^�Nô —L’L °QÔ7×?Ñ?ÀÓOÐR`Õ`ß‘$“&˜4×+Ñ+õ ,�ð
  ,×1Ñ1°!°T·_±_ÀqÕ5HÓI�ä‰w‰˜|Ó,¨lÐ:Ð:r!   c                ó"   <€ \         SV `  V4      # r®   )r±   r¿   )rž   rT   rµ   s   &&€r    Ú_forwardÚ'ProphetNetPositionalEmbeddings._forward}  s   ø€ Ü‰w‰˜|Ó,Ð,r!   )r°   )NNN)rr   rs   rt   ru   rv   r²   r¿   rÆ   rx   ry   Ú__classcell__©rµ   ro   s   @@r    r©   r©   V  s%   ù‡ € ñ÷bó b÷;÷8-õ -r!   r©   c                   ó\   a a€ ] tR tRt oRtRV3R lV 3R llltR	V3R lR lltRtVtV ;t	# )
ÚProphetNetAttentioni�  z=Multi-headed attention from 'Attention Is All You Need' paperc                ó:   <€ V ^8„  d   QhRS[ RS[RS[R,          /# )r^   r•   Únum_attn_headsÚ	layer_idxN©r   r?   )rn   ro   s   "€r    rp   Ú ProphetNetAttention.__annotate__„  s*   ø€ ÷ <ñ <Ñ/ð <Áð <ÑQTÐW[ÕQ[ñ <r!   c                óÈ  <€ \         SV `  4        VP                  pVP                  V n        VP                  V n        W n        WB,          V n        W0n        V P                  V,          V8X  g   Q R 4       h\        P                  ! WD4      V n
        \        P                  ! WD4      V n        \        P                  ! WD4      V n        \        P                  ! WD4      V n        R# )zw`config.hidden_size` must be divisible by `config.num_encoder_attention_heads` and `config.num_decoder_attention_heads`N)r±   r²   r³   Úattention_dropoutÚdropoutrÍ   Úhead_dimrÎ   r   ÚLinearÚkey_projÚ
value_projÚ
query_projÚout_proj)rž   r•   rÍ   rÎ   r³   rµ   s   &&&& €r    r²   ÚProphetNetAttention.__init__„  s¬   ø€ Ü‰ÑÔØ×(Ñ(ˆà!'×!9Ñ!9ˆÔØ—~‘~ˆŒØ,ÔØ#Õ5ˆŒØ"Œà�}‰}˜~Õ-°Ô<ð 	
ð4ó	
Ð<ô
 Ÿ	š	 +Ó;ˆŒÜŸ)š) KÓ=ˆŒÜŸ)š) KÓ=ˆŒäŸ	š	 +Ó;ˆŽr!   c                ó”   <€ V ^8„  d   QhRS[ R,          RS[ R,          RS[R,          RS[R,          RS[S[ S[ R,          3,          /# )r^   Úkey_value_statesNrÁ   rb   Úoutput_attentionsr«   )r   r   Úboolrm   )rn   ro   s   "€r    rp   rÐ   ™  sd   ø€ ÷ [2ñ [2ñ ! 4�-ð[2ñ  �ð	[2ñ
  �ð[2ñ   $�;ð[2ñ 
‰v‘v •}Ð$Õ	%ñ[2r!   c                ó,	  € VP                  4       w  rxp	VR Jp
\        VP                  4       4      VVV	.8X  g   Q RWxV	3 RVP                  4        24       hV P                  V4      V P                  R,          ,          pRpVe`   \	        V\
        4      '       dH   VP                  P                  V P                  4      pV
'       d   VP                  pMVP                  pMTpV
'       d   TMTpV
'       d\   VeX   V'       dP   XP                  V P                  ,          P                  pVP                  V P                  ,          P                  pMíV P                  V4      pV P                  V4      pVP!                  VRV P"                  V P                  4      P%                  ^^4      pVP!                  VRV P"                  V P                  4      P%                  ^^4      pVeX   XP'                  VVV P                  4      w  ppV
'       d0   \	        V\
        4      '       d   RVP                  V P                  &   VP!                  WxV P"                  V P                  4      P%                  ^^4      pVP                  ^4      p\(        P*                  ! RW¿P%                  ^^4      4      pWpP"                  VV3pVP                  4       V8w  d    \-        RV RVP                  4        24      hVe   VP/                  4       ^ 8X  d   R pWpP"                  ^V3pVe5   VP                  4       V8w  d    \-        RV RVP                  4        24      hVe
   VV,           pV'       d   TpMR p\0        P2                  P5                  VRR	7      p\0        P2                  P7                  VV P8                  V P:                  R
7      p\(        P*                  ! RVV4      pWpP"                  W€P                  3pVP                  4       V8w  d    \-        RV RVP                  4        24      hVP%                  ^^4      P=                  WxV	4      pV P?                  V4      p\0        P2                  P7                  VV P6                  V P:                  R
7      pVV3# )Nz Size of hidden states should be z	, but is ç      à?FTzbsij,bsjk->bsikz#Attention weights should have size z Attention mask should have size r   ©ÚpÚtrainingz `attn_output` should have shape ú, but is of shape rP   ) rS   ÚlistrØ   rÔ   Ú
isinstancer	   Ú
is_updatedÚgetrÎ   Úcross_attention_cacheÚself_attention_cacheÚlayersÚkeysÚvaluesrÖ   r×   r)   rÍ   Ú	transposeÚupdater   ÚeinsumÚ
ValueErrorr   r   r   r   rÓ   rÒ   rã   ÚreshaperÙ   )rž   r„   rÜ   rÁ   rb   rÝ   ÚkwargsÚ
batch_sizeÚtgt_lenr³   Úis_cross_attentionÚquery_statesrç   Úcurr_past_key_valuesÚcurrent_statesÚ
key_statesÚvalue_statesÚsrc_lenÚattn_weightsÚexpected_shapeÚattn_weights_reshapedÚ
attn_probsÚattn_outputs   &&&&&&,                r    r¿   ÚProphetNetAttention.forward™  s0  € ð ,9×+=Ñ+=Ó+?Ñ(ˆ
˜[ð .°TÐ9ÐÜ�M×&Ñ&Ó(Ó)ØØØð.
ô 
ð 	pð .¨jÀ;Ð.NÐ-OÈyÐYf×YkÑYkÓYmÐXnÐoó		pð 
ð —‘ }Ó5¸¿¹ÈÕ9KÕLˆàˆ
ØÒ&Ü˜/Ô+>×?Ò?Ø,×7Ñ7×;Ñ;¸D¿N¹NÓK�
ß%à+:×+PÑ+PÑ(à+:×+OÑ+OÑ(à'6Ð$ç-?Ñ)À]ˆß /Ò"=Ç*à-×4Ñ4°T·^±^ÕD×IÑIˆJØ/×6Ñ6°t·~±~ÕF×MÑM‰LàŸ™ ~Ó6ˆJØŸ?™?¨>Ó:ˆLØ#Ÿ™¨°R¸×9LÑ9LÈdÏmÉmÓ\×fÑfÐghÐjkÓlˆJØ'×,Ñ,¨Z¸¸T×=PÑ=PÐRV×R_ÑR_Ó`×jÑjÐklÐnoÓpˆLàÒ*à+?×+FÑ+FÀzÐS_Ðae×aoÑaoÓ+pÑ(�
˜Lç%¬*°_ÔFY×*ZÒ*ZØAE�O×.Ñ.¨t¯~©~Ñ>à#×(Ñ(¨¸d×>QÑ>QÐSW×S`ÑS`Óa×kÑkÐlmÐopÓqˆØ—/‘/ !Ó$ˆä—|’|Ð$5°|×EYÑEYÐZ[Ð]^ÓE_Ó`ˆØ$×&9Ñ&9¸7ÀGÐLˆØ×ÑÓ .Ô0ÜÐBÀ>ÐBRÐR[Ð\h×\mÑ\mÓ\oÐ[pÐqÓrÐrð Ò%¨.×*<Ñ*<Ó*>À!Ô*CØ!ˆNà$×&9Ñ&9¸1¸gÐFˆØÒ%¨.×*=Ñ*=Ó*?À>Ô*QÜÐ?ÀÐ?OÈyÐYg×YlÑYlÓYnÐXoÐpÓqÐqØÒ%Ø'¨.Õ8ˆLßØ$0Ñ!à$(Ð!ä—}‘}×,Ñ,¨\¸rÐ,ÓBˆä—]‘]×*Ñ*ØØ×$Ñ$Ø—]‘]ð +ó 
ˆ
ô
 —l’lÐ#4°jÀ,ÓOˆØ$×&9Ñ&9¸7ÇMÁMÐRˆØ×ÑÓ Ô/ÜÐ?ÀÐ?OÐOaÐbm×brÑbrÓbtÐauÐvÓwÐwà!×+Ñ+¨A¨qÓ1×9Ñ9¸*È{Ó[ˆØ—m‘m KÓ0ˆä—m‘m×+Ñ+¨K¸4¿<¹<ÐRV×R_ÑR_Ð+Ó`ˆØÐ1Ð1Ð1r!   )	rÒ   rÓ   rÔ   rÖ   rÎ   rÍ   rÙ   rØ   r×   r®   )NNNF©
rr   rs   rt   ru   rv   r²   r¿   rx   ry   rÈ   rÉ   s   @@r    rË   rË   �  s$   ù‡ € ÙG÷<õ <÷*[2÷ [2ò [2r!   rË   c                   óH   a a€ ] tR tRt oRtV3R lV 3R lltR tRtVtV ;t	# )ÚProphetNetFeedForwardi÷  ze
This is the residual two feed-forward layer block based on the original Transformer implementation.
c                ó&   <€ V ^8„  d   QhRS[ RS[/# )r^   r•   Úffn_dimrÏ   )rn   ro   s   "€r    rp   Ú"ProphetNetFeedForward.__annotate__ü  s   ø€ ÷ &ñ &Ñ/ð &¹#ñ &r!   c                ó6  <€ \         SV `  4        \        VP                  ,          V n        \
        P                  ! VP                  V4      V n        \
        P                  ! W!P                  4      V n	        VP                  V n
        VP                  V n        R # r®   )r±   r²   r   Úactivation_functionÚactivation_fnr   rÕ   r³   ÚintermediateÚoutputÚactivation_dropoutrÓ   )rž   r•   r  rµ   s   &&&€r    r²   ÚProphetNetFeedForward.__init__ü  si   ø€ Ü‰ÑÔÜ# F×$>Ñ$>Õ?ˆÔÜŸIšI f×&8Ñ&8¸'ÓBˆÔÜ—i’i ×);Ñ);Ó<ˆŒØ"(×";Ñ";ˆÔØ—~‘~ˆŽr!   c                ó@  € V P                  V4      pV P                  V4      p\        P                  P	                  WP
                  V P                  R 7      pV P                  V4      p\        P                  P	                  WP                  V P                  R 7      pV# )rá   )r  r  r   r   rÓ   r  rã   r  )rž   r„   s   &&r    r¿   ÚProphetNetFeedForward.forward  s€   € Ø×)Ñ)¨-Ó8ˆØ×*Ñ*¨=Ó9ˆäŸ™×-Ñ-¨m×?VÑ?VÐae×anÑanÐ-ÓoˆØŸ™ MÓ2ˆÜŸ™×-Ñ-¨m¿|¹|ÐVZ×VcÑVcÐ-ÓdˆØÐr!   )r  r  rÓ   r  r  r  rÉ   s   @@r    r  r  ÷  s   ù‡ € ñ÷&ó &÷ò r!   r  c                   óp   a a€ ] tR tRt oRV3R lV 3R llltR tR tRV3R lR lltR tR	 t	R
t
VtV ;t# )ÚProphetNetNgramSelfAttentioni  c                ó    <€ V ^8„  d   QhRS[ /# r¤   r   )rn   ro   s   "€r    rp   Ú)ProphetNetNgramSelfAttention.__annotate__  s   ø€ ÷  ñ  Ñ/ñ  r!   c                óØ  <€ \         SV `  4        VP                  V n        VP                  V n        VP                  V n        VP
                  V n        VP                  V n        VP                  V n        VP                  V P                  ,          V n	        VP                  V n
        W n        V P                  V P                  ,          VP                  8X  g   Q R 4       h\        P                  ! VP                  VP                  4      V n        \        P                  ! VP                  VP                  4      V n        \        P                  ! VP                  VP                  4      V n        \        P                  ! VP                  VP                  4      V n        \        P                  ! VP                  V P                  V P                  ,          4      V n        RV n        R# )z6config.hidden_size must be divisible by num_attn_headsFN)r±   r²   r³   rE   Úrelative_max_distanceÚnum_decoder_attention_headsrÍ   rÓ   rÒ   rÔ   r0   rÎ   r   rÕ   rÖ   r×   rØ   rÙ   Úrelative_pos_embeddingsr   ©rž   r•   rÎ   rµ   s   &&&€r    r²   Ú%ProphetNetNgramSelfAttention.__init__  sf  ø€ Ü‰ÑÔØ!×-Ñ-ˆÔà!×-Ñ-ˆÔØ%+×%AÑ%AˆÔ"Ø$×@Ñ@ˆÔØ—~‘~ˆŒØ!'×!9Ñ!9ˆÔØ×*Ñ*¨d×.AÑ.AÕAˆŒØ—\‘\ˆŒ
Ø"Œà�}‰}˜t×2Ñ2Õ2°f×6HÑ6HÔHð 	
ØDó	
ÐHô Ÿ	š	 &×"4Ñ"4°f×6HÑ6HÓIˆŒÜŸ)š) F×$6Ñ$6¸×8JÑ8JÓKˆŒÜŸ)š) F×$6Ñ$6¸×8JÑ8JÓKˆŒô Ÿ	š	 &×"4Ñ"4°f×6HÑ6HÓIˆŒô (*§y¢y°×1CÑ1CÀT×EUÑEUÐX\×XkÑXkÕEkÓ'lˆÔ$ð  ˆŽr!   c                óŒ   € VP                  W2V P                  V P                  4      P                  ^^4      P	                  4       # )r’   )r)   rÍ   rÔ   rî   Ú
contiguous)rž   ÚtensorÚseq_lenrô   s   &&&&r    Ú_shapeÚ#ProphetNetNgramSelfAttention._shape-  s7   € Ø�{‰{˜:°×0CÑ0CÀTÇ]Á]ÓS×]Ñ]Ð^_ÐabÓc×nÑnÓpÐpr!   c                ó   € R V n         R# )TN)r   ©rž   s   &r    Úprepare_for_onnx_export_Ú5ProphetNetNgramSelfAttention.prepare_for_onnx_export_0  s	   € ØˆŽr!   c                ó.   <€ V ^8„  d   QhRS[ R,          /# )r^   rb   N)r   )rn   ro   s   "€r    rp   r  3  s!   ø€ ÷ a@ñ a@ñ  �ña@r!   c           	     óü  € VP                  4       w  ršp\        VP                  4       4      WšV.8X  g   Q R WšV3 RVP                   24       hV P                  V4      pV P	                  V4      pV P                  V4      pWÀP                  R,          ,          pV P                  WÊV	4      pV P                  VR
V	4      pV P                  VR
V	4      pW�P                  R
V P                  3pVP                  ! V!  pVP                  ! V!  pVP                  ! V!  pVP                  ^V P                  ,           ^R7      pVP                  ^V P                  ,           ^R7      pVP                  ^V P                  ,           ^R7      pVP                  ^V P                  ,           ^R7      pV^ ,          VR,          ppV^ ,          VR,          ppV^ ,          VR,          ppV^ ,          VR,          ppVeF   \        V\        4      '       d   VP                  pMTpVP                  VVV P                   4      w  ppV
^V P                  ,           ,          p\"        P$                  ! RVVP'                  ^^4      4      pV P)                  VVWu4      pVV,           pVe
   VV,           p\+        VR
V P,                  R7      P/                  V4      p \0        P2                  P5                  V V P6                  V P8                  R7      p \"        P$                  ! RV V4      p!V!P'                  ^^4      P                  V	^VV4      p!V P;                  V!4      p!\"        P<                  ! V^4      P?                  W�P                  V P                  VV P                  4      p"\"        P<                  ! V U#u. uF  p#\"        P@                  ! VV#.^4      NK  	  up#^4      p$\"        P<                  ! V^R7      p%\"        P@                  ! V U&u. uF+  p&\"        P@                  ! VV&.^4      PC                  ^4      NK-  	  up&^4      p'\"        P$                  ! RV"V$34      p(V PE                  V%V(Wv4      p)V(V),           p(Ve:   VPG                  ^ ^^^^4      pVPI                  V(PJ                  4      pV(V,           p(\+        V(R
V P,                  R7      P/                  V(4      p*\0        P2                  P5                  V*V P6                  V P8                  R7      p*\"        P$                  ! R	V*V'P'                  ^^4      34      p+V+P'                  ^^4      p+V+P                  W�P                  VV4      p+V P;                  V+4      p+\"        P@                  ! V!V+.^4      P?                  V	R
V4      p,V P?                  W�P                  VR
4      p \0        P2                  P5                  V,V P4                  V P8                  R7      p,V,V V*3# u up#i u up&i )z#`hidden_states` should be of shape rä   rà   r   r‘   zbntc,bncs->bnts)r   r   rá   zbnhtc,bnhsc->bnhtszbnhts,bnhsc->bnhtcrP   )&rS   rå   r™   rØ   rÖ   r×   rÔ   r   rÍ   rò   Úchunkr0   ræ   r	   rê   rï   rÎ   r   rð   rî   Ú get_main_relative_pos_embeddingsr   r   r½   r   r   rÓ   rÒ   rã   rÙ   Ústackr)   r.   rQ   Ú#get_predict_relative_pos_embeddingsÚpermuteÚtor   )-rž   r„   rb   rÁ   Úextended_predict_attention_maskrW   rX   rT   ró   rô   Úngram_sequence_lengthr³   r÷   rú   rû   Ú
proj_shapeÚhidden_states_listÚquery_states_listÚkey_states_listÚvalue_states_listÚmain_hidden_statesÚhidden_states_predict_listÚmain_query_statesÚpredict_query_states_listÚmain_key_statesÚpredict_key_states_listÚmain_value_statesÚpredict_value_states_listrø   r/   Úmain_attn_weightsÚmain_relative_pos_embeddingsÚmain_attn_probsÚmain_attn_outputÚpredict_query_statesÚkeyÚpredict_key_statesÚpredict_hidden_statesÚv_pÚpredict_value_statesÚpredict_attn_weightsÚpredict_relative_pos_embeddingsÚpredict_attn_probsÚpredict_attn_outputr  s-   &&&&&&&&,                                    r    r¿   Ú$ProphetNetNgramSelfAttention.forward3  sê  € ð :G×9KÑ9KÓ9MÑ6ˆ
¨;Ü�M×&Ñ&Ó(Ó)¨jÐQ\Ð-]Ô]ð 	
Ø1°*ÐU`Ð2`Ð1að bØ×#Ñ#Ð$ð&ó	
Ð]ð —‘ }Ó5ˆØ—]‘] =Ó1ˆ
Ø—‘ }Ó5ˆð $§}¡}°cÕ'9Õ:ˆð —{‘{ <È
ÓSˆØ—[‘[ ¨R°Ó<ˆ
Ø—{‘{ <°°ZÓ@ˆØ ×"5Ñ"5°r¸4¿=¹=ÐIˆ
à#×+Ò+¨ZÑ8ˆØ×'Ò'¨Ñ4ˆ
Ø#×+Ò+¨ZÑ8ˆð +×0Ñ0°°T·Z±ZµÀQÐ0ÓGÐØ(×.Ñ.¨q°4·:±:­~À1Ð.ÓEÐØ$×*Ñ*¨1¨t¯z©z­>¸qÐ*ÓAˆØ(×.Ñ.¨q°4·:±:­~À1Ð.ÓEÐà9KÈAÕ9NÐPbÐceÕPfÐ6ÐØ7HÈÕ7KÐM^Ð_aÕMbÐ4ÐØ3BÀ1Õ3EÀÐWYÕGZÐ0ˆØ7HÈÕ7KÐM^Ð_aÕMbÐ4Ðð Ò&Ü˜/Ô+>×?Ò?Ø'6×'KÑ'KÑ$à'6Ð$Ø1E×1LÑ1LØÐ!2°D·N±Nó2Ñ.ˆOÐ.ð
 0°A¸¿
¹
µNÕCˆô "ŸLšLÐ):Ð<MÈ×OhÑOhÐijÐlmÓOnÓoÐð (,×'LÑ'LØÐ 1°<ó(
Ð$ð .Ð0LÕLÐàÒ%Ø 1°NÕ BÐä!ØØØ—‘ô
÷ ‰'Ð#Ó
$ð	 	ô Ÿ-™-×/Ñ/°À4×CYÑCYÐdh×dqÑdqÐ/Órˆô
 !Ÿ<š<Ð(9¸?ÐL]Ó^Ðà+×5Ñ5°a¸Ó;×CÑCÀJÐPQÐSbÐdoÓpÐØŸ=™=Ð)9Ó:Ðô  %Ÿ{š{Ð+DÀaÓH×MÑMØŸ
™
 D×$7Ñ$7¸È$Ï-É-ó 
Ðô
 #Ÿ[š[ÑZqÓ)rÑZqÐSV¬%¯)ª)°_ÀcÐ4JÈAÖ*NÑZqÑ)rÐtuÓvÐô !&§¢Ð,FÈAÔ NÐô  %ŸyšyÙLeÓfÑLeÀSŒU�YŠYÐ)¨3Ð/°Ó3×=Ñ=¸aÖ@ÑLeÑfÐhió 
Ðô  %Ÿ|š|Ð,@ÐCWÐYkÐBlÓmÐð +/×*RÑ*RØ!Ð#7¸ó+
Ð'ð
  4Ð6UÕUÐà*Ò6à.M×.UÑ.UÐVWÐYZÐ\]Ð_`ÐbcÓ.dÐ+Ø.M×.PÑ.PÐQe×QkÑQkÓ.lÐ+Ø#7Ð:YÕ#YÐ ä$Ø ØØ—‘ô
÷ ‰'Ð&Ó
'ð	 	ô  Ÿ]™]×2Ñ2Ø $×"8Ñ"8À4Ç=Á=ð 3ó 
Ðô $ŸlšlØ Ð#5Ð7K×7UÑ7UÐVWÐYZÓ7[Ð"\ó
Ðð 2×;Ñ;¸A¸qÓAÐØ1×9Ñ9¸*ÇjÁjÐRaÐcnÓoÐØ"Ÿm™mÐ,?Ó@Ðô —i’iÐ!1Ð3FÐ GÈÓK×PÑPÐQ[Ð]_ÐalÓmˆà)×.Ñ.¨z×;NÑ;NÐP_ÐacÓdˆä—m‘m×+Ñ+¨K¸4¿<¹<ÐRV×R_ÑR_Ð+Ó`ˆà˜OÐ-?Ð?Ð?ùò{ *sùò gs   Î+"W4Ð1W9c                óL  € VP                   w  rVrxVP                  WVWx4      pVfÕ   VP                   R,          w  rY\        P                  ! ^VP                   R,          ^,           4      P	                  ^ 4      P	                  ^ 4      P                  WY^4      P                  VP                  4      p
W£P	                  ^ 4      P                  WY^4      ,
          p
\        V P                  V P                  V
R4      pV P                  V4      pVP                  VP                   R,          V P                  V P                  3,           4      pVP                  ^ ^^^4      pVP                  VP                   R,          R,           4      pVP                  ^V P                  ^4      pVP                  RVP                   R,          4      pVP                  4       pVP                  RVP!                  R4      4      p\        P"                  ! V^VR7      pVP                  WVVR4      pV# )NºNr^   NF:Né   N©r   ÚindexrP   )rP   )r™   r)   r   r(   rQ   rR   r-  r#   rN   rE   r  r  rÍ   r,  rò   r»   rS   Úgather)rž   r„   rý   rT   rW   rô   rÍ   rõ   rü   r/   rG   Úrel_pos_embeddingsr>  s   &&&&&        r    r)  Ú=ProphetNetNgramSelfAttention.get_main_relative_pos_embeddingsÖ  sþ  € ð 8D×7IÑ7IÑ4ˆ
 GØ#×(Ñ(¨ÀWÓVˆØ)Ò1Ø*7×*=Ñ*=¸bÕ*AÑ'ˆJä—’˜Q × 2Ñ 2°2Õ 6¸Õ :Ó;ß‘˜1“ß‘˜1“ß‘˜
°QÓ7ß‘�L×'Ñ'Ó(ð ð "4×6LÑ6LÈQÓ6O×6VÑ6VÐWaÐtuÓ6vÕ!vÐÜ-EØ× Ñ  $×"<Ñ"<Ð>PÐRWó.Ð*ð
 "×9Ñ9¸-ÓHÐØ/×4Ñ4Ø×$Ñ$ RÕ(¨D×,<Ñ,<¸d×>QÑ>QÐ+RÕRó
Ðð 0×7Ñ7¸¸1¸aÀÓCÐà/×7Ñ7¸×8JÑ8JÈ2Õ8NÐQVÕ8VÓWÐà)G×)NÑ)NÈqÐRV×ReÑReÐghÓ)iÐ&à)G×)LÑ)LØÐ.×4Ñ4°RÕ8ó*
Ð&ð *H×)LÑ)LÓ)NÐ&à/×7Ñ7¸Ð<N×<SÑ<SÐTVÓ<WÓXÐä',§|¢|Ð4FÈAÐUsÔ'tÐ$Ø'C×'HÑ'HÈÐelÐnpÓ'qÐ$Ø+Ð+r!   c                ód  € VP                   R ,          w  rVVfß   VP                   R,          p\        V^ ,          ^ ,          V^,
          8H  R4       \        P                  ! ^ V4      P	                  ^ 4      P	                  ^ 4      P                  WV^4      P                  VP                  4      pWƒP	                  ^ 4      P                  WV^4      ,
          p\        V P                  V P                  VR4      pVP                  ^^4      pV P                  V4      p	V	P                  VP                   RR V P                  V P                  3,           4      p	V	P                  ^ ^^^^4      p	V	P!                  RV P                  4      p	VP	                  ^ 4      pVP                  V P"                  ^V P                  ^4      pVP                  RVP%                  R4      4      P'                  4       p\        P(                  ! V	^VR7      p
V
P                  WPP"                  V P                  VR4      p
V
# ):r“   r^   NNzb`position_ids` are incorrect. They should be of the format 1 2 3 4 5 ... (key_sequence_length - 1)FrO  rP   )r™   r   r   r(   rQ   rR   r-  r#   rN   rE   r  rî   r  r)   rÍ   r,  rò   r0   rS   r»   rQ  )rž   r„   rý   rT   rX   rô   r/   Úkey_sequence_lengthrG   rR  rH  s   &&&&&      r    r+  Ú@ProphetNetNgramSelfAttention.get_predict_relative_pos_embeddings  s  € ð '4×&9Ñ&9¸#Õ&>Ñ#ˆ
à,Ò4Ø".×"4Ñ"4°RÕ"8ÐÜ"Ø˜Q• Õ"Ð&9¸AÕ&=Ñ=Øtôô
 —’˜QÐ 3Ó4ß‘˜1“ß‘˜1“ß‘˜
°QÓ7ß‘�L×'Ñ'Ó(ð ð "4×6LÑ6LÈQÓ6O×6VÑ6VÐWaÐtuÓ6vÕ!vÐÜ0HØ× Ñ  $×"<Ñ"<Ð>PÐRWó1Ð-ð
 &×/Ñ/°°1Ó5ˆØ!×9Ñ9¸-ÓHÐð 0×4Ñ4Ø×Ñ  Ð$¨×(8Ñ(8¸$×:MÑ:MÐ'NÕNó
Ðð 0×7Ñ7¸¸1¸aÀÀAÓFÐà/×7Ñ7¸¸D×<LÑ<LÓMÐà,M×,WÑ,WÐXYÓ,ZÐ)Ø,M×,TÑ,TØ�J‰J˜˜4×.Ñ.°ó-
Ð)ð -N×,RÑ,RØÐ1×6Ñ6°rÓ:ó-
ç
‰$‹&ð 	*ô +0¯,ª,Ø AÐ-Nô+
Ð'ð
 +J×*NÑ*NØŸ
™
 D×$7Ñ$7¸È"ó+
Ð'ð /Ð.r!   )rÒ   rÓ   rÔ   r³   rÖ   rÎ   r0   rÍ   rE   r   rÙ   rØ   r  r  r×   r®   ©NNNNNN)rr   rs   rt   ru   r²   r   r$  r¿   r)  r+  rx   ry   rÈ   rÉ   s   @@r    r  r    s9   ù‡ € ÷ õ  ò<qò÷a@ò a@òF+,÷Z:/ò :/r!   r  c                   óX   a a€ ] tR tRt oRtV3R lV 3R lltRV3R lR lltRtVtV ;t	# )	ÚProphetNetEncoderLayeri@  z
Encoder block for Prophetnet
c                ó    <€ V ^8„  d   QhRS[ /# r¤   r   )rn   ro   s   "€r    rp   Ú#ProphetNetEncoderLayer.__annotate__E  s   ø€ ÷ Eñ EÑ/ñ Er!   c                óô   <€ \         SV `  4        \        WP                  4      V n        \        VP                  4      V n        \        WP                  4      V n
        \        VP                  4      V n        R # r®   )r±   r²   rË   Únum_encoder_attention_headsÚ	self_attnr   r³   Úself_attn_layer_normr  Úencoder_ffn_dimÚfeed_forwardÚfeed_forward_layer_normr´   s   &&€r    r²   ÚProphetNetEncoderLayer.__init__E  s[   ø€ Ü‰ÑÔä,¨V×5WÑ5WÓXˆŒÜ$-¨f×.@Ñ.@Ó$AˆÔ!ô 2°&×:PÑ:PÓQˆÔÜ'0°×1CÑ1CÓ'DˆÖ$r!   c                ó    <€ V ^8„  d   QhRS[ /# )r^   rÝ   ©rÞ   )rn   ro   s   "€r    rp   r[  O  s   ø€ ÷ ñ ñ  ñ	r!   c                óØ   € V P                  VVVR 7      w  rEV P                  WA,           4      pV P                  V4      pV P                  Wa,           4      pV3pV'       d
   Wu3,          pV# ))r„   rÁ   rÝ   )r^  r_  ra  rb  )rž   r„   rÁ   rÝ   Úattention_outputrý   Úfeed_forward_outputÚoutputss   &&&&    r    r¿   ÚProphetNetEncoderLayer.forwardO  s{   € ð *.¯©Ø'Ø)Ø/ð *8ó *
Ñ&Ðð
 ×1Ñ1Ð2BÕ2RÓSˆð #×/Ñ/°Ó>ÐØ×4Ñ4Ð5HÕ5XÓYˆà Ð"ˆçØ�Õ&ˆGàˆr!   )ra  rb  r^  r_  ©Fr  rÉ   s   @@r    rY  rY  @  s%   ù‡ € ñ÷Eó E÷÷ ò r!   rY  c                   ó\   a a€ ] tR tRt oRtRV3R lV 3R llltR	V3R lR lltRtVtV ;t	# )
ÚProphetNetDecoderLayerii  z
Decoder block for Prophetnet
c                ó    <€ V ^8„  d   QhRS[ /# r¤   r   )rn   ro   s   "€r    rp   Ú#ProphetNetDecoderLayer.__annotate__n  s   ø€ ÷ Eñ EÑ/ñ Er!   c                ór  <€ \         SV `  4        \        WR 7      V n        \	        VP
                  4      V n        VP                  '       d7   \        WP                  VR 7      V n
        \	        VP
                  4      V n        \        WP                  4      V n        \	        VP
                  4      V n        R# )©rÎ   N)r±   r²   r  r^  r   r³   r_  Úadd_cross_attentionrË   r  Ú
cross_attnÚcross_attn_layer_normr  Údecoder_ffn_dimra  rb  r  s   &&&€r    r²   ÚProphetNetDecoderLayer.__init__n  s‹   ø€ Ü‰ÑÔä5°fÔRˆŒÜ$-¨f×.@Ñ.@Ó$AˆÔ!ð ×%×%Ð%Ü1°&×:\Ñ:\ÐhqÔrˆDŒOÜ)2°6×3EÑ3EÓ)FˆDÔ&ô 2°&×:PÑ:PÓQˆÔÜ'0°×1CÑ1CÓ'DˆÖ$r!   c                óB   <€ V ^8„  d   QhRS[ R,          RS[ R,          /# )r^   Ú	use_cacheNrÝ   re  )rn   ro   s   "€r    rp   ro  }  s)   ø€ ÷ 0ñ 0ñ ˜$•;ð0ñ   $�;ñ0r!   c           
     óV  € V P                  VV	VVVVVR 7      w  rÞpV P                  W,           4      pRpVe2   V P                  VVVV	VR7      w  ppV P                  VV,           4      pV P	                  V4      pV P                  VV,           4      pV3pV'       d   VWïV3,          pV# ))r„   rb   rÁ   r.  rW   rX   rT   N)r„   rÜ   rÁ   rb   rÝ   )r^  r_  rs  rt  ra  rb  )rž   r„   rÁ   ri   Úencoder_attn_maskr.  rW   rX   rT   rb   rx  rÝ   ró   Úngram_attention_outputÚself_attn_weightsÚself_attn_weights_ngramÚcross_attn_weightsrg  rh  ri  s   &&&&&&&&&&&&,       r    r¿   ÚProphetNetDecoderLayer.forward}  så   € ð  NRÏ^É^Ø'Ø+Ø)Ø,KØ+IØ.OØ%ð N\ó N
ÑJÐÐ3Jð ×1Ñ1°-Õ2XÓYˆà!ÐØ Ò,à37·?±?Ø+Ø!6Ø0Ø /Ø"3ð 4Có 4Ñ0ÐÐ0ð !×6Ñ6Ð7GÈ-Õ7WÓXˆMð #×/Ñ/°Ó>ÐØ×4Ñ4Ð5HÈ=Õ5XÓYˆà Ð"ˆçØÐ)ÐDVÐWÕWˆGàˆr!   )rs  rt  ra  rb  r^  r_  r®   )
NNNNNNNNTFr  rÉ   s   @@r    rm  rm  i  s%   ù‡ € ñ÷Eõ E÷0÷ 0ò 0r!   rm  z=
    The standalone encoder part of the ProphetNetModel.
    c                   ój   a a€ ] tR tRt oV3R lV 3R lltR tR t]R	V3R lR ll4       tRt	Vt
V ;t# )
ÚProphetNetEncoderi°  c                ó    <€ V ^8„  d   QhRS[ /# r¤   r   )rn   ro   s   "€r    rp   ÚProphetNetEncoder.__annotate__¶  s   ø€ ÷ ñ Ñ/ñ r!   c                ó¸  <€ \         SV `  V4       \        P                  ! VP                  VP
                  VP                  R 7      V n        \        V4      V n	        \        VP
                  4      V n        \        P                  ! \        VP                  4       Uu. uF  p\        V4      NK  	  up4      V n        RV n        V P%                  4        R# u upi )©r¸   FN)r±   r²   r   Ú	EmbeddingÚ
vocab_sizer³   r—   Úword_embeddingsr©   Úposition_embeddingsr   Úembeddings_layer_normÚ
ModuleListÚrangeÚnum_encoder_layersrY  rë   Úgradient_checkpointingÚ	post_init)rž   r•   Ú_rµ   s   && €r    r²   ÚProphetNetEncoder.__init__¶  s£   ø€ Ü‰Ñ˜Ô ä!Ÿ|š|¨F×,=Ñ,=¸v×?QÑ?QÐ_e×_rÑ_rÔsˆÔÜ#AÀ&Ó#IˆÔ Ü%.¨v×/AÑ/AÓ%BˆÔ"ä—m’mÌUÐSY×SlÑSlÔMmÓ$nÑMmÈÔ%;¸FÖ%CÑMmÑ$nÓoˆŒà&+ˆÔ#à�‰Öùò	 %os   ÂCc                ó   € V P                   # r®   ©rˆ  r#  s   &r    Úget_input_embeddingsÚ&ProphetNetEncoder.get_input_embeddingsÃ  ó   € Ø×#Ñ#Ð#r!   c                ó   € Wn         R # r®   r“  ©rž   Úvalues   &&r    Úset_input_embeddingsÚ&ProphetNetEncoder.set_input_embeddingsÆ  ó   € Ø$Ör!   c                óä   <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[R,          RS[R,          RS[S[,          /# )	r^   rŸ   NrÁ   Úinputs_embedsrÝ   Úoutput_hidden_statesÚreturn_dictr«   )r   r   rÞ   rm   r   )rn   ro   s   "€r    rp   rƒ  Ê  s†   ø€ ÷ N
ñ N
á—<‘< $Õ&ðN
ñ Ÿ™ tÕ+ðN
ñ —|‘| dÕ*ð	N
ñ
   $�;ðN
ñ # T�kðN
ñ ˜D•[ðN
ñ 
‘Õ	 ñN
r!   c                óÜ  € Ve   TMV P                   P                  pVe   TMV P                   P                  pVe   TMV P                   P                  pVf   Vf   \	        R4      hVe   Ve   \	        R4      hVe   Vf   V P                  V4      pVe‚   RVR
,          P                  ^V P                   P                  ^^4      ,
          \        P                  ! V P                  4      P                  ,          pVP                  VP                  4      pMRpV P                  VP                  R,          VP                  4      w  ršW9,           pV P!                  V4      p\"        P$                  P'                  W°P                   P&                  V P(                  R7      pV'       d   RMRpV'       d   RMRp\+        V P,                  4       FE  w  rïV'       d
   WË3,           pV! VVVR7      pV^ ,          pV'       g   K4  VV^,          3,           pKG  	  V'       d
   WË3,           pV'       g1   \.        ;QJ d    . R W¼V3 4       F  NK  	  5# ! R W¼V3 4       4      # \1        W¼VR	7      # )a¹  
Example:

```python
>>> from transformers import AutoTokenizer, ProphetNetEncoder
>>> import torch

>>> tokenizer = AutoTokenizer.from_pretrained("microsoft/prophetnet-large-uncased")
>>> model = ProphetNetEncoder.from_pretrained("patrickvonplaten/prophetnet-large-uncased-standalone")
>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
>>> outputs = model(**inputs)

>>> last_hidden_states = outputs.last_hidden_state
```Nz3Either input_ids or inputs_embeds has to be passed.z2Make sure to only pass input_ids or inputs_embeds.ç      ð?rM  rá   )rÁ   rÝ   c              3   ó0   "  € T F  qf   K  Vx € K  	  R # 5ir®   r%   ©Ú.0Úvs   & r    Ú	<genexpr>Ú,ProphetNetEncoder.forward.<locals>.<genexpr>  s   é € ÐlÑ$Z˜qŸšÓ$Zùó   ‚Œ
)r~   r„   r†   ©ºNNNNNr«  r%   )r•   rÝ   rŸ  r   rñ   rˆ  rR   r]  r   r&   r   r'   r-  r‰  r™   r#   rŠ  r   r   rÓ   rã   Ú	enumeraterë   rm   r   )rž   rŸ   rÁ   rž  rÝ   rŸ  r   ró   Úextended_attention_maskr‰  rT   r„   ri   Úall_attentionsÚidxÚencoder_layerÚlayer_outputss   &&&&&&&,         r    r¿   ÚProphetNetEncoder.forwardÉ  s8  € ð4 2CÒ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ò$DÑ È$Ï+É+×JjÑJjð 	ð &1Ò%<‘kÀ$Ç+Á+×BYÑBYˆàÒ Ò!6ÜÐRÓSÐSØÒ" }Ò'@ÜÐQÓRÐRØÒ" }Ò'<Ø ×0Ñ0°Ó;ˆMð Ò%à�nÐ%5Õ6×=Ñ=¸aÀÇÁ×AhÑAhÐjkÐmnÓoÕoÜ—’˜DŸJ™JÓ'×+Ñ+õ',Ð#ð '>×&@Ñ&@À×ATÑATÓ&UÑ#à&*Ð#à,0×,DÑ,DÀ]×EXÑEXÐY[ÕE\Ð^k×^rÑ^rÓ,sÑ)Ðà%Õ;ˆØ×2Ñ2°=ÓAˆÜŸ™×-Ñ-¨m¿{¹{×?RÑ?RÐ]a×]jÑ]jÐ-Ókˆç&:¡ÀÐß0™°dˆä"+¨D¯K©KÖ"8ÑˆCß#Ø(=Ð@PÕ(PÐ%á)ØØ6Ø"3ôˆMð *¨!Õ,ˆMç Ñ Ø!/°=ÀÕ3CÐ2EÕ!E’ñ #9÷  Ø$9Ð<LÕ$LÐ!çß”5Ñl ]È>Ñ$ZÓl—5Ðl�5Ñl ]È>Ñ$ZÓlÓlÐlÜØ+Ð]kô
ð 	
r!   )rŠ  rŽ  rë   r‰  rˆ  rW  )rr   rs   rt   ru   r²   r”  rš  r   r¿   rx   ry   rÈ   rÉ   s   @@r    r�  r�  °  s;   ù‡ € ÷ó ò$ò%ð ÷N
ñ N
ó ÷N
ð N
r!   r�  z=
    The standalone decoder part of the ProphetNetModel.
    c                   ó|   a a€ ] tR tRt oV3R lV 3R lltR tR t]RV3R lR ll4       tR t	R	 t
R
 tRtVtV ;t# )ÚProphetNetDecoderi  c                ó    <€ V ^8„  d   QhRS[ /# r¤   r   )rn   ro   s   "€r    rp   ÚProphetNetDecoder.__annotate__!  s   ø€ ÷ ñ Ñ/ñ r!   c           
     óÆ  <€ \         SV `  V4       VP                  V n        VP                  V n        VP                  V n        VP
                  V n        VP                  V n        \        P                  ! VP                  VP                  VP                  R 7      V n        \        V4      V n        \        P                  ! V P                  VP                  R4      V n        \        P"                  ! \%        VP&                  4       Uu. uF  p\)        WR7      NK  	  up4      V n        \-        VP                  4      V n        RV n        V P3                  4        R# u upi )r…  Nrq  F)r±   r²   r0   rE   r  rÓ   r¯   Úmax_target_positionsr   r†  r‡  r³   r—   rˆ  r©   r‰  Úngram_embeddingsr‹  rŒ  Únum_decoder_layersrm  rë   r   rŠ  rŽ  r�  )rž   r•   Úirµ   s   && €r    r²   ÚProphetNetDecoder.__init__!  s  ø€ Ü‰Ñ˜Ô à—\‘\ˆŒ
Ø!×-Ñ-ˆÔØ%+×%AÑ%AˆÔ"Ø—~‘~ˆŒØ$*×$BÑ$BˆÔ!ä!Ÿ|š|¨F×,=Ñ,=¸v×?QÑ?QÐ_e×_rÑ_rÔsˆÔÜ#AÀ&Ó#IˆÔ ä "§¢¨T¯Z©Z¸×9KÑ9KÈTÓ RˆÔÜ—m’mÜBGÈ×HaÑHaÔBbÓcÑBb¸QÔ# F×8ÑBbÑcó
ˆŒô &/¨v×/AÑ/AÓ%BˆÔ"à&+ˆÔ#à�‰Öùò ds   Ä
Ec                ó   € V P                   # r®   r“  r#  s   &r    r”  Ú&ProphetNetDecoder.get_input_embeddings7  r–  r!   c                ó   € Wn         R # r®   r“  r˜  s   &&r    rš  Ú&ProphetNetDecoder.set_input_embeddings:  rœ  r!   c                ó\  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[ P                  R,          RS[R,          R	S[R,          R
S[R,          RS[R,          RS[S[,          /# )r^   rŸ   NrÁ   ri   Úencoder_attention_maskrb   rž  rx  rÝ   rŸ  r   r«   )r   r   r   rÞ   rm   r‚   )rn   ro   s   "€r    rp   r¶  >  sÍ   ø€ ÷ y
ñ y
á—<‘< $Õ&ðy
ñ Ÿ™ tÕ+ðy
ñ  %Ÿ|™|¨dÕ2ð	y
ñ
 !&§¡¨tÕ 3ðy
ñ  �ðy
ñ —|‘| dÕ*ðy
ñ ˜$•;ðy
ñ   $�;ðy
ñ # T�kðy
ñ ˜D•[ðy
ñ 
Ñ-Õ	-ñy
r!   c                ó@  € Ve   TMV P                   P                  pVe   TMV P                   P                  pV	e   T	MV P                   P                  p	V
e   T
MV P                   P                  p
Vf   Vf   \        R4      hVe   Ve   \        R4      hVe   Vf   V P                  V4      pVP                  R,          w  rÍV P                  '       d2   V P                  '       d    V'       d   \        P                  R4       RpV'       do   Vfk   Vf   V P                   P                  '       d5   \        \        V P                   R7      \        V P                   R7      4      M\        V P                   R7      pVe   VP                  4       M^ pV P!                  WÍ3VP"                  VR7      w  ppV^ 8w  d   RRppMV P%                  V4      w  ppV P                   P'                  V^,           4      pWo,           pV P(                  P*                  pV^ 8w  dm   VP-                  ^4      ^8X  g   Q R	4       h\/        V P0                  4       Uu. uF+  pVV^,
          ,          V,           P3                  V^^4      NK-  	  ppRpRpM]\/        V P0                  4       Uu. uF  pVV^,
          ,          V,           NK  	  ppV P5                  VV4      pV P7                  VV4      pVe‚   R
VR,          P3                  ^V P                   P8                  ^^4      ,
          \:        P<                  ! V P>                  4      P@                  ,          pVPC                  VP>                  4      pMRp\:        PD                  ! V.V,           ^4      pV PF                  '       d   V PG                  V4      p\H        PJ                  PM                  VV PL                  V P                  R7      pV	'       d   RMRpV	'       d   V P                   P0                  ^ 8”  d   RMRpV'       d   RMRpV'       d   RMRpV'       d   V P                   PN                  '       d   RMRp\Q        V PR                  4       FÊ  w  p p!V	'       dF   VVRRV13,          3,          pV P                   P0                  ^ 8”  d   VVRVR13,          3,          pV!! VVVVVVVVVVVR7      p"V"^ ,          pV'       g   Ky  VV"^,          3,          pVV"^,          3,          pV P                   PN                  '       g   K¹  VV"^,          3,          pKÌ  	  V	'       dF   VVRRV13,          3,          pV P                   P0                  ^ 8”  d   VVRVR13,          3,          pVRRV13,          p#V P                   P0                  ^ 8”  d   VRVR13,          MRp$V
'       g=   \T        ;QJ d    . R V#V$VVVVVV3 4       F  NK  	  5# ! R V#V$VVVVVV3 4       4      # \W        V#V$VVVVVVR7      # u upi u upi )aÂ  
Example:

```python
>>> from transformers import AutoTokenizer, ProphetNetDecoder
>>> import torch

>>> tokenizer = AutoTokenizer.from_pretrained("microsoft/prophetnet-large-uncased")
>>> model = ProphetNetDecoder.from_pretrained("microsoft/prophetnet-large-uncased", add_cross_attention=False)
>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
>>> outputs = model(**inputs)

>>> last_hidden_states = outputs.last_hidden_state
```NzGEither `decoder_input_ids` or `decoder_inputs_embeds` has to be passed.zFMake sure to only pass `decoder_input_ids` or `decoder_inputs_embeds`.rM  zZ`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`...F)r•   )r#   rb   zOAt the moment `use_cache` is only supported for `decoder_input_ids` of length 1r¢  r«  rá   )rz  r.  rW   rX   rT   rb   rx  rÝ   c              3   ó2   "  € T F  pVf   K	  Vx € K  	  R # 5ir®   r%   r¤  s   & r    r§  Ú,ProphetNetDecoder.forward.<locals>.<genexpr>à  s"   é € ð ñ	�Að ÷ ’ó	ùs   ‚�
)r~   r   rb   r„   r…   r†   r‡   rg   rª  r%   ),r•   rx  rÝ   rŸ  r   rñ   rˆ  r™   rŽ  rã   ÚloggerÚwarning_onceÚis_encoder_decoderr	   r   r¹   r‰  r#   Ú!compute_buffered_relative_bucketsrÆ   r¹  ÚweightrS   rŒ  r0   rR   Úprepare_attention_maskÚprepare_predict_attention_maskr  r   r&   r   r'   r-  r.   rŠ  r   r   rÓ   rr  r¬  rë   rm   r‚   )%rž   rŸ   rÁ   ri   rÂ  rb   rž  rx  rÝ   rŸ  r   ró   rô   r/   Úpast_key_values_lengthÚmain_stream_pos_embedrT   rW   rX   Úpredicting_stream_pos_embedr„   r¹  r0   Úngram_hidden_statesr­  r.  Úextended_encoder_attention_maskÚall_main_stream_hidden_statesÚall_ngram_stream_hidden_statesÚall_main_stream_attnsÚall_ngram_stream_attnsÚall_cross_attnsr¯  Údecoder_layerr±  r~   r   s%   &&&&&&&&&&&,                         r    r¿   ÚProphetNetDecoder.forward=  s*  € ð: "+Ò!6‘I¸D¿K¹K×<QÑ<Qˆ	Ø1BÒ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ò$DÑ È$Ï+É+×JjÑJjð 	ð &1Ò%<‘kÀ$Ç+Á+×BYÑBYˆàÒ Ò!6ÜÐfÓgÐgØÒ" }Ò'@ÜÐeÓfÐfØÒ" }Ò'<Ø ×0Ñ0°Ó;ˆMà&3×&9Ñ&9¸"Õ&=Ñ#ˆ
à×&×&Ð&¨4¯=¯=¨=ßÜ×#Ñ#Øpôð "�	ç˜Ò0ð )Ò4¸¿¹×8V×8VÐ8Vô $¤L¸¿¹Ô$DÄlÐZ^×ZeÑZeÔFfÔgä!¨¯©Ô5ð ð FUÒE` ×!?Ñ!?Ô!AÐfgÐà.2×.FÑ.FØÐ)Ø ×'Ñ'Ø+ð /Gó /
Ñ+Ð˜|ð " QÔ&ØPTÐVZÐ,MÐ*Ð,Mð
 ×6Ñ6°|ÓDñØ.Ø1à&*×&>Ñ&>×&GÑ&GÈÐWXÕHXÓ&YÐ#ð &Õ=ˆà×0Ñ0×7Ñ7Ðð " QÔ&Ø ×%Ñ% aÓ(¨AÔ-ð ØaóÐ-ô # 4§:¡:Ô.ó#á.�Eð " %¨!¥)Õ,Ð/JÕJ×RÑRÐS]Ð_`ÐbcÖdÙ.ð  ð #ð '+Ð#Ø.2Ñ+ô Z_Ð_c×_iÑ_iÔYjó#ÙYjÐPUÐ! %¨!¥)Õ,Ð/J×JÐJÑYjð  ð #ð '+×&AÑ&AÀ-ÐQ_Ó&`Ð#Ø.2×.QÑ.QÐR_ÐaoÓ.pÐ+ð "Ò-àÐ,Ð-=Õ>×EÑEÀaÈÏÉ×IpÑIpÐrsÐuvÓwÕwÜ—’˜DŸJ™JÓ'×+Ñ+õ/,Ð+ð /N×.PÑ.PÐQ^×QdÑQdÓ.eÑ+à.2Ð+äŸ	š	 = /Ð4GÕ"GÈÓKˆà×%×%Ð%Ø ×6Ñ6°}ÓEˆMäŸ™×-Ñ-¨m¸t¿|¹|ÐVZ×VcÑVcÐ-Ódˆ÷ /C©ÈÐ%ß/CÈÏÉ×HYÑHYÐ\]ÔH]©ÐcgÐ&ç&7¡¸TÐß'8¡¸dÐß 1°d·k±k×6U×6UÐ6U™"Ð[_ˆä"+¨D¯K©KÖ"8ÑˆC�ß#à-°-ÀÐCSÀOÐCSÐ@SÕ2TÐ1VÕVÐ-Ø—;‘;×$Ñ$ qÔ(Ø2°}ÀQÈÑHXÐEXÕ7YÐ6[Õ[Ð2á)ØØ'Ø%Ø"AØ0OØ/MØ2SØ)Ø /Ø#Ø"3ôˆMð *¨!Õ,ˆMß Ñ Ø%¨-¸Õ*:Ð)<Õ<Ð%Ø&¨=¸Õ+;Ð*=Õ=Ð&à—;‘;×2×2Ò2Ø#¨°aÕ(8Ð':Õ:’Oñ7 #9÷:  Ø)¨m¸AÐ?OÀÐ?OÐ<OÕ.PÐ-RÕRÐ)Ø�{‰{× Ñ  1Ô$Ø.°=ÀÀOÑDTÐATÕ3UÐ2WÕWÐ.ð *¨!Ð-=¨oÐ-=Ð*=Õ>ÐØHLÏÉ×HYÑHYÐ\]ÔH] -°°?Ñ3CÐ0CÖ"DÐcgÐçß”5ñ ð &Ø+Ø#Ø1Ø2Ø)Ø*Ø#ñ	ó—5ð �5ñ ð &Ø+Ø#Ø1Ø2Ø)Ø*Ø#ñ	óó ð ô ,Ø/Ø$;Ø+Ø7Ø >Ø,Ø3Ø,ô	
ð 		
ùòu#ùò#s   É1XÊ  Xc           	     ó  € VP                   w  r#\        P                  ! ^V P                  4      P	                  VP
                  4      P                  ^^4      p\        V P                  V P                  V4      w  rEVRRV1RV13,          P                  V^^4      p\        P                  ! VRRV1RV13,          VRRV1V P                  V P                  V,           13,          .^4      P                  V^^4      pWE3# )r’   r«  N)r™   r   r(   r¸  r-  r#   rR   rY   rE   r  r.   )rž   rT   rô   r/   Úmain_relative_bucketsÚpredict_relative_bucketss   &&    r    rÉ  Ú3ProphetNetDecoder.compute_buffered_relative_bucketsù  s  € Ø&2×&8Ñ&8Ñ#ˆ
ä—|’| A t×'@Ñ'@ÓA×DÑDÀ\×EXÑEXÓY×`Ñ`ÐabÐdeÓfˆÜ:]Ø×Ñ˜d×8Ñ8¸,ó;
Ñ7Ðð
 !6°aÐ9I¸/Ð9IÐK[ÈOÐK[Ð6[Õ \× cÑ cÐdnÐpqÐstÓ uÐÜ#(§9¢9à(¨Ð,<¨_Ð,<Ð>N¸Ð>NÐ)NÕOØ(ØÐ'˜Ð'¨×)BÑ)BÀT×E^ÑE^ÐapÕEpÐ)pÐpõðð ó$
÷ ‰&�˜Q Ó
"ð 	!ð %Ð>Ð>r!   c                óp  € VP                   R ,          w  r4\        P                  ! WD3\        P                  ! VP                  4      P
                  VP                  VP                  R7      p\        P                  ! V^4      pVRV1RV13,          R,          P                  W0P                  P                  3VP                   ,           4      pVeI   RVR,          ,
          \        P                  ! V P                  4      P
                  ,          pWg,           pMTpVP                  VP                  4      # )rM  r$   Nr¢  )NNr«  r«  rª  )r™   r   r+   r&   r   r'   r#   Útriur*   r•   r  r-  )rž   r„   rÁ   rô   Ú
seq_lengthÚcausal_maskÚextended_causal_maskr­  s   &&&     r    rË  Ú(ProphetNetDecoder.prepare_attention_mask  s  € Ø!.×!4Ñ!4°RÕ!8Ñˆ
ô —j’jØÐ$Ü�KŠK˜×+Ñ+Ó,×0Ñ0Ø×%Ñ%Ø ×'Ñ'ô	
ˆô —j’j ¨aÓ0ˆà*¨;¨J¨;¸¸¸Ð+CÕDÐEUÕV×]Ñ]ØŸ™×@Ñ@ÐAÀK×DUÑDUÕUó 
Ðð
 Ò%Ø'*¨^Ð<LÕ-MÕ'MÔQV×Q\ÒQ\Ð]a×]gÑ]gÓQh×QlÑQlÕ&lÐ#Ø&:Õ&TÑ#à&:Ð#Ø&×)Ñ)¨-×*=Ñ*=Ó>Ð>r!   c           	     óH  € VP                   R ,          w  r4\        V P                  V P                  VP                  VP
                  4      p\        P                  ! VRRV1RV13,          VRRV1V P                  V P                  V,           13,          .RR7      pVR,          P                  W0P                  P                  3VP                   ,           4      pVe©   RVR,          ,
          \        P                  ! V P
                  4      P                  ,          pVP                  W0P                  P                  V P                  WD34      p\        P                  ! V\        P                  ! V4      .RR7      pWg,           pMTpVP                  VP
                  4      # )rM  r«  Nr   r¢  rP   )NNr«  r«  r«  )r«  NNNr«  )r™   r;   r¸  r0   r#   r   r   r.   r*   r•   r  r&   r'   r>   r-  )	rž   r„   rÁ   rô   rß  Úpredict_causal_maskÚextended_predict_causal_maskr­  r.  s	   &&&      r    rÌ  Ú0ProphetNetDecoder.prepare_predict_attention_mask'  s‡  € Ø!.×!4Ñ!4°RÕ!8Ñˆ
ô 3Ø×%Ñ% t§z¡z°=×3GÑ3GÈ×I\ÑI\ó
Ðô $Ÿišià# A {¨
 {°K°Z°KÐ$?Õ@Ø#Ø�{˜
�{ D×$=Ñ$=À×@YÑ@YÐ\fÕ@fÐ$fÐfõðð ô
Ðð (;Ð;NÕ'O×'VÑ'VØŸ™×@Ñ@ÐAÐDW×D]ÑD]Õ]ó(
Ð$ð
 Ò%Ø'*¨^Ð<RÕ-SÕ'SÔW\×WbÒWbÐcg×cmÑcmÓWn×WrÑWrÕ&rÐ#Ø&=×&DÑ&DØŸ[™[×DÑDÀdÇjÁjÐR\Ðió'Ð#ô ',§i¢iØ(¬%×*:Ò*:Ð;RÓ*SÐTÐZ\ô'Ð#ð /KÕ.dÑ+à.JÐ+Ø.×1Ñ1°-×2EÑ2EÓFÐFr!   )rÓ   rŠ  rŽ  rë   r¸  r0   r¹  rE   r‰  r  rˆ  )
NNNNNNNNNN)rr   rs   rt   ru   r²   r”  rš  r   r¿   rÉ  rË  rÌ  rx   ry   rÈ   rÉ   s   @@r    r´  r´    sL   ù‡ € ÷ó ò,$ò%ð ÷y
ñ y
ó ðy
òv?ò,?÷0!Gò !Gr!   r´  c                   óv   a a€ ] tR tRt oRRRR/tV3R lV 3R lltR tR t]RV3R	 lR
 ll4       t	Rt
VtV ;t# )ÚProphetNetModeliK  zencoder.word_embeddings.weightúword_embeddings.weightúdecoder.word_embeddings.weightc                ó    <€ V ^8„  d   QhRS[ /# r¤   r   )rn   ro   s   "€r    rp   ÚProphetNetModel.__annotate__R  s   ø€ ÷ ñ Ñ/ñ r!   c                ór  <€ \         SV `  V4       \        P                  ! VP                  VP
                  VP                  R 7      V n        \        P                  ! V4      pRVn
        \        V4      V n        \        P                  ! V4      pRVn        \        V4      V n        V P!                  4        R# )r…  FTN)r±   r²   r   r†  r‡  r³   r—   rˆ  ÚcopyÚdeepcopyrx  r�  ÚencoderÚ
is_decoderr´  Údecoderr�  )rž   r•   Úencoder_configÚdecoder_configrµ   s   &&  €r    r²   ÚProphetNetModel.__init__R  sˆ   ø€ Ü‰Ñ˜Ô Ü!Ÿ|š|¨F×,=Ñ,=¸v×?QÑ?QÐ_e×_rÑ_rÔsˆÔäŸš vÓ.ˆØ#(ˆÔ Ü(¨Ó8ˆŒäŸš vÓ.ˆØ$(ˆÔ!Ü(¨Ó8ˆŒð 	�‰Ör!   c                ó   € V P                   # r®   r“  r#  s   &r    r”  Ú$ProphetNetModel.get_input_embeddingsa  r–  r!   c                ó~   € Wn         V P                   V P                  n         V P                   V P                  n         R # r®   )rˆ  rð  rò  r˜  s   &&r    rš  Ú$ProphetNetModel.set_input_embeddingsd  s,   € Ø$ÔØ'+×';Ñ';ˆ�‰Ô$Ø'+×';Ñ';ˆ�‰Ö$r!   c                ó˜  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[R,          RS[ P                  R,          R	S[ P                  R,          R
S[R,          RS[R,          RS[R,          RS[R,          RS[S[,          /# )r^   rŸ   NrÁ   Údecoder_input_idsÚdecoder_attention_maskÚencoder_outputsrb   rž  Údecoder_inputs_embedsrx  rÝ   rŸ  r   r«   )r   r   Ú
BoolTensorrm   r   rÞ   r|   )rn   ro   s   "€r    rp   rì  j  sò   ø€ ÷ ^
ñ ^
á—<‘< $Õ&ð^
ñ Ÿ™ tÕ+ð^
ñ !Ÿ<™<¨$Õ.ð	^
ñ
 !&× 0Ñ 0°4Õ 7ð^
ñ  �ð^
ñ  �ð^
ñ —|‘| dÕ*ð^
ñ  %Ÿ|™|¨dÕ2ð^
ñ ˜$•;ð^
ñ   $�;ð^
ñ # T�kð^
ñ ˜D•[ð^
ñ 
Ñ-Õ	-ñ^
r!   c                ó„  € V	e   T	MV P                   P                  p	V
e   T
MV P                   P                  p
Ve   TMV P                   P                  pVe   TMV P                   P                  pVf   V P                  VVVV
VVR7      pV P                  VVV^ ,          VVVV
VV	VR7
      pV'       g	   Wå,           # \        VP                  VP                  VP                  VP                  VP                  VP                  VP                  VP                  VP                  VP                  VP                  R7      # )a1  
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
    Indices of decoder input sequence tokens in the vocabulary.

    Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
    [`PreTrainedTokenizer.__call__`] for details.

    [What are decoder input IDs?](../glossary#decoder-input-ids)

    ProphetNet uses the `eos_token_id` as the starting token for `decoder_input_ids` generation. If
    `past_key_values` is used, optionally only the last `decoder_input_ids` have to be input (see
    `past_key_values`).
decoder_attention_mask (`torch.BoolTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
    Default behavior: generate a tensor that ignores pad tokens in `decoder_input_ids`. Causal mask will also
    be used by default.

Example:

```python
>>> from transformers import AutoTokenizer, ProphetNetModel

>>> tokenizer = AutoTokenizer.from_pretrained("microsoft/prophetnet-large-uncased")
>>> model = ProphetNetModel.from_pretrained("microsoft/prophetnet-large-uncased")

>>> input_ids = tokenizer(
...     "Studies have been shown that owning a dog is good for you", return_tensors="pt"
... ).input_ids  # Batch size 1
>>> decoder_input_ids = tokenizer("Studies show that", return_tensors="pt").input_ids  # Batch size 1
>>> outputs = model(input_ids=input_ids, decoder_input_ids=decoder_input_ids)

>>> last_hidden_states = outputs.last_hidden_state  # main stream hidden states
>>> last_hidden_states_ngram = outputs.last_hidden_state_ngram  # predict hidden states
```)rŸ   rÁ   rž  rÝ   rŸ  r   )
rŸ   rÁ   ri   rÂ  rb   rž  rÝ   rŸ  rx  r   )r~   r   rb   rc   rd   re   rf   rg   rh   ri   rj   )r•   rx  rÝ   rŸ  r   rð  rò  r|   r~   r   rb   r„   r…   r†   r‡   rg   )rž   rŸ   rÁ   rû  rü  rý  rb   rž  rþ  rx  rÝ   rŸ  r   ró   Údecoder_outputss   &&&&&&&&&&&&&, r    r¿   ÚProphetNetModel.forwardi  sI  € ðd "+Ò!6‘I¸D¿K¹K×<QÑ<Qˆ	Ø1BÒ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ò$DÑ È$Ï+É+×JjÑJjð 	ð &1Ò%<‘kÀ$Ç+Á+×BYÑBYˆàÒ"Ø"Ÿl™lØ#Ø-Ø+Ø"3Ø%9Ø'ð +ó ˆOð Ÿ,™,Ø'Ø1Ø"1°!Õ"4Ø#1Ø+Ø/Ø/Ø!5ØØ#ð 'ó 
ˆ÷ Ø"Õ4Ð4Ü+Ø-×?Ñ?Ø$3×$KÑ$KØ+×;Ñ;Ø"1×"?Ñ"?Ø(7×(KÑ(KØ.×9Ñ9Ø%4×%EÑ%EØ,×=Ñ=Ø&5×&GÑ&GØ"1×"?Ñ"?Ø.×9Ñ9ô
ð 	
r!   )rò  rð  rˆ  )NNNNNNNNNNNN)rr   rs   rt   ru   Ú_tied_weights_keysr²   r”  rš  r   r¿   rx   ry   rÈ   rÉ   s   @@r    rè  rè  K  sQ   ù‡ € ð 	)Ð*BØ(Ð*BðÐ÷
ó ò$ò<ð
 ÷^
ñ ^
ó ÷^
ð ^
r!   rè  zh
    The ProphetNet Model with a language modeling head. Can be used for sequence generation tasks.
    c                   ó˜   a a€ ] tR tRt oRR/tV3R lV 3R lltR t]RV3R lR ll4       tRR	 lt	V3R
 lR lt
RV 3R lltRtVtV ;t# )Ú"ProphetNetForConditionalGenerationiË  úlm_head.weightú!prophetnet.word_embeddings.weightc                ó    <€ V ^8„  d   QhRS[ /# r¤   r   )rn   ro   s   "€r    rp   Ú/ProphetNetForConditionalGeneration.__annotate__Õ  s   ø€ ÷ 	ñ 	Ñ/ñ 	r!   c                ó  <€ \         SV `  V4       \        V4      V n        VP                  V n        VP                  V n        \        P                  ! VP                  VP                  R R7      V n        V P                  4        R# )F©ÚbiasN)r±   r²   rè  r�   r—   r¸   Údisable_ngram_lossr   rÕ   r³   r‡  Úlm_headr�  r´   s   &&€r    r²   Ú+ProphetNetForConditionalGeneration.__init__Õ  sd   ø€ Ü‰Ñ˜Ô Ü)¨&Ó1ˆŒØ!×.Ñ.ˆÔØ"(×";Ñ";ˆÔä—y’y ×!3Ñ!3°V×5FÑ5FÈUÔSˆŒð 	�‰Ör!   c                ó.   € V P                   P                  # r®   )r�   rˆ  r#  s   &r    r”  Ú7ProphetNetForConditionalGeneration.get_input_embeddingsà  s   € Ø�‰×.Ñ.Ð.r!   c                óÔ  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[ P                  R,          R	S[ P                  R,          R
S[ P                  R,          RS[R,          RS[R,          RS[R,          RS[R,          RS[S[,          /# )r^   rŸ   NrÁ   rû  rü  rý  rb   rž  rþ  Úlabelsrx  rÝ   rŸ  r   r«   )r   r   rÿ  r   rÞ   rm   r\   )rn   ro   s   "€r    rp   r	  ä  s  ø€ ÷ mñ má—<‘< $Õ&ðmñ Ÿ™ tÕ+ðmñ !Ÿ<™<¨$Õ.ð	mñ
 !&× 0Ñ 0°4Õ 7ðmñ Ÿ™¨Õ,ðmñ  �ðmñ —|‘| dÕ*ðmñ  %Ÿ|™|¨dÕ2ðmñ —‘˜tÕ#ðmñ ˜$•;ðmñ   $�;ðmñ # T�kðmñ ˜D•[ðmñ  
Ñ*Õ	*ñ!mr!   c                óþ  € Ve   TMV P                   P                  pV	e   Vf   Vf   V P                  V	4      pV P                  VVVVVVVVV
VVVR7      pVe   VP                  MVP                  R,          w  ppV^,          P                  VV P                   P                  VR4      pV P                  V4      pVR,          pV P                   P                  ^8”  d
   VR	,          MRpVP                  4       '       g   VP                  4       pRpV	e   V P                  VV	4      pV'       g]   \        ;QJ d    . R VV3 4       F  NK  	  5M! R VV3 4       4      pVe   V3V,           VR,          ,           # VVR,          ,           # \        VVVVP                  VP                  VP                  VP                   VP"                  VP$                  VP&                  VP(                  VP*                  R7      # )
a¥  
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
    Indices of decoder input sequence tokens in the vocabulary.

    Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
    [`PreTrainedTokenizer.__call__`] for details.

    [What are decoder input IDs?](../glossary#decoder-input-ids)

    ProphetNet uses the `eos_token_id` as the starting token for `decoder_input_ids` generation. If
    `past_key_values` is used, optionally only the last `decoder_input_ids` have to be input (see
    `past_key_values`).
decoder_attention_mask (`torch.BoolTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
    Default behavior: generate a tensor that ignores pad tokens in `decoder_input_ids`. Causal mask will also
    be used by default.
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
    Labels for computing the sequence classification/regression loss. Indices should be in `[-100, 0, ...,
    config.vocab_size - 1]`. All labels set to `-100` are ignored (masked), the loss is only computed for
    labels in `[0, ..., config.vocab_size]`

Example:

```python
>>> from transformers import AutoTokenizer, ProphetNetForConditionalGeneration

>>> tokenizer = AutoTokenizer.from_pretrained("microsoft/prophetnet-large-uncased")
>>> model = ProphetNetForConditionalGeneration.from_pretrained("microsoft/prophetnet-large-uncased")

>>> input_ids = tokenizer(
...     "Studies have been shown that owning a dog is good for you", return_tensors="pt"
... ).input_ids  # Batch size 1
>>> decoder_input_ids = tokenizer("Studies show that", return_tensors="pt").input_ids  # Batch size 1
>>> outputs = model(input_ids=input_ids, decoder_input_ids=decoder_input_ids)

>>> logits_next_token = outputs.logits  # logits to predict next token as usual
>>> logits_ngram_next_tokens = outputs.logits_ngram  # logits to predict 2nd, 3rd, ... next tokens
```N)rŸ   rÁ   rû  rü  rý  rb   rž  rþ  rx  rÝ   rŸ  r   rM  c              3   ó0   "  € T F  qf   K  Vx € K  	  R # 5ir®   r%   r¤  s   & r    r§  Ú=ProphetNetForConditionalGeneration.forward.<locals>.<genexpr>A  ó   é € ÐRÑ*@ QŸqšqÓ*@ùr©  ºr^   NN)r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rP   ©r«  r“   ©r«  r‘   )r•   r   r¡   r�   r™   r)   r0   r  Úis_contiguousr  Ú_compute_lossrm   r\   rb   rc   rd   re   rf   rg   rh   ri   rj   )rž   rŸ   rÁ   rû  rü  rý  rb   rž  rþ  r  rx  rÝ   rŸ  r   ró   ri  rô   r/   Úpredicting_streamsÚpredict_logitsr`   ra   r_   Ú
all_logitss   &&&&&&&&&&&&&&,         r    r¿   Ú*ProphetNetForConditionalGeneration.forwardã  sô  € ðn &1Ò%<‘kÀ$Ç+Á+×BYÑBYˆàÒÐ"3Ò";Ð@UÒ@]à $× 1Ñ 1°&Ó 9Ðà—/‘/ØØ)Ø/Ø#9Ø+Ø+Ø'Ø"7ØØ/Ø!5Ø#ð "ó 
ˆð (9Ò'DÐ×#Ò#ÐJ_×JeÑJeÐfhÕJiñ 	$ˆ
�Oð % Q�ZŸ_™_¨Z¸¿¹×9JÑ9JÈOÐ]_Ó`ÐØŸ™Ð&8Ó9ˆà Õ%ˆØ04·±×0AÑ0AÀAÔ0E�~ eÖ,È4ˆð ×#Ñ#×%Ò%Ø×&Ñ&Ó(ˆFàˆØÒØ×%Ñ% n°fÓ=ˆDçßœÑR¨6°<Ñ*@ÓRŸ™ÑR¨6°<Ñ*@ÓRÓRˆJØ9=Ò9I�D�7˜ZÕ'¨'°"­+Õ5ÐgÈzÐ\cÐdfÕ\gÕOgÐgä,ØØØ)Ø '× 7Ñ 7Ø&-×&CÑ&CØ,3×,OÑ,OØ#*×#=Ñ#=Ø)0×)IÑ)IØ!(×!9Ñ!9Ø*1×*KÑ*KØ&-×&CÑ&CØ#*×#=Ñ#=ôð r!   c                ó  € VP                  V P                  P                  VP                  ^ 4      VP                  ^4      4      P	                  V4      p\        V P                  P                  4       F%  pV^ 8”  d   V P                  '       d    MW$VRR3&   K'  	  VP                  ^ ^4      P                  4       p\        P                  P                  VP                  R	VP                  R	4      4      R	\        P                  R7      p\        P                  P                  WdP                  R	4      RR7      pV P                  P                   R8”  dª   VP#                  R	RR7      ) pVP%                  V4      P                  R	4      p	W‰,          pVP'                  4       pV P                  P                   VP                  R	4      ,          p
RV P                  P                   ,
          V,          W¨,          ,           pV# ©
r“   r«  r   Úmean)Ú	reductiong        T)r   Úkeepdimr¢  rP   ©r˜   r•   r0   rS   Úfill_rŒ  r  rî   r  r   r   Úlog_softmaxr)   r   r   Únll_lossÚepsÚsumÚner#  ©rž   r`   r  Úignore_indexÚexpend_targetsr»  Úlprobsr_   Úsmooth_lossÚnon_masked_tokensÚeps_is   &&&&       r    r  Ú0ProphetNetForConditionalGeneration._compute_lossS  ó‹  € Ø×)Ñ)¨$¯+©+×*;Ñ*;¸V¿[¹[È»^ÈVÏ[É[ÐYZË^Ó\×bÑbÐcoÓpˆä�t—{‘{×(Ñ(Ö)ˆAØ�1Œu˜×0×0Ð0ÙØ&,˜1˜a ˜7Ó#ñ *ð
 ×!Ñ! ! QÓ'×2Ñ2Ó4ˆÜ—‘×*Ñ*Ø�K‰K˜˜FŸK™K¨›OÓ,ØÜ—-‘-ð +ó 
ˆô �}‰}×%Ñ% f×.AÑ.AÀ"Ó.EÐQWÐ%ÓXˆà�;‰;�?‰?˜SÔ Ø!Ÿ:™:¨"°d˜:Ó;Ð;ˆKØ .× 1Ñ 1°,Ó ?× DÑ DÀRÓ HÐØ%Õ8ˆKØ%×*Ñ*Ó,ˆKà—K‘K—O‘O f§k¡k°"£oÕ5ˆEØ˜$Ÿ+™+Ÿ/™/Õ)¨TÕ1°EÕ4GÕGˆDàˆr!   c                ó4   <€ V ^8„  d   QhRS[ P                  /# )r^   r  )r   r   )rn   ro   s   "€r    rp   r	  o  s   ø€ ÷ )ñ )¹E¿L¹Lñ )r!   c                ó$   € V P                  V4      # r®   )r¡   )rž   r  s   &&r    Ú%prepare_decoder_input_ids_from_labelsÚHProphetNetForConditionalGeneration.prepare_decoder_input_ids_from_labelso  s   € Ø× Ñ  Ó(Ð(r!   c                óX   <€ Vf   V P                   P                  # \        SV `  VR7      # )N)Úmodality)r�   rð  r±   Úget_encoder)rž   r;  rµ   s   &&€r    r<  Ú.ProphetNetForConditionalGeneration.get_encoderr  s,   ø€ ØÒØ—?‘?×*Ñ*Ð*ä‘7Ñ&°Ð&Ó9Ð9r!   ©r  r  r¸   r�   )NNNNNNNNNNNNN©r”   r®   )rr   rs   rt   ru   r  r²   r”  r   r¿   r  r8  r<  rx   ry   rÈ   rÉ   s   @@r    r  r  Ë  sZ   ù‡ € ð 	Ð=ðÐ÷	ó 	ò/ð ÷mñ mó ðmô^÷8)ð )÷:÷ :r!   r  zt
    The standalone decoder part of the ProphetNetModel with a lm head on top. The model can be used for causal
    c                   ó€   a a€ ] tR tRt oRRRR/tV3R lV 3R lltR tR t]RV3R	 lR
 ll4       t	RR lt
RtVtV ;t# )ÚProphetNetForCausalLMiy  r  r  z)prophetnet.decoder.word_embeddings.weightc                ó    <€ V ^8„  d   QhRS[ /# r¤   r   )rn   ro   s   "€r    rp   Ú"ProphetNetForCausalLM.__annotate__„  s   ø€ ÷ ñ Ñ/ñ r!   c                óV  <€ \         P                  ! V4      pR Vn        RVn        \        SV `  V4       \        V4      V n        VP                  V n	        VP                  V n
        \        P                  ! VP                  VP                  RR7      V n        V P!                  4        R# )TFr  N)rî  rï  rñ  rÈ  r±   r²   ÚProphetNetDecoderWrapperr�   r—   r¸   r  r   rÕ   r³   r‡  r  r�  r´   s   &&€r    r²   ÚProphetNetForCausalLM.__init__„  s‚   ø€ ä—’˜vÓ&ˆØ ˆÔØ$)ˆÔ!Ü‰Ñ˜Ô Ü2°6Ó:ˆŒà!×.Ñ.ˆÔØ"(×";Ñ";ˆÔä—y’y ×!3Ñ!3°V×5FÑ5FÈUÔSˆŒð 	�‰Ör!   c                óB   € V P                   P                  P                  # r®   ©r�   rò  rˆ  r#  s   &r    r”  Ú*ProphetNetForCausalLM.get_input_embeddings”  s   € Ø�‰×&Ñ&×6Ñ6Ð6r!   c                ó:   € WP                   P                  n        R # r®   rH  r˜  s   &&r    rš  Ú*ProphetNetForCausalLM.set_input_embeddings—  s   € Ø27�‰×ÑÖ/r!   c                ó„  <€ V ^8„  d   QhRS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[ P                  R,          RS[R,          RS[ P                  R,          RS[ P                  R,          R	S[R,          R
S[R,          RS[R,          RS[R,          RS[S[,          /# )r^   rŸ   NrÁ   ri   rÂ  rb   rž  r  rx  rÝ   rŸ  r   r«   )r   r   r   rÞ   rm   rŠ   )rn   ro   s   "€r    rp   rC  ›  sá   ø€ ÷ dñ dá—<‘< $Õ&ðdñ Ÿ™ tÕ+ðdñ  %Ÿ|™|¨dÕ2ð	dñ
 !&§¡¨tÕ 3ðdñ  �ðdñ —|‘| dÕ*ðdñ —‘˜tÕ#ðdñ ˜$•;ðdñ   $�;ðdñ # T�kðdñ ˜D•[ðdñ 
Ñ*Õ	*ñdr!   c                óB  € Ve   TMV P                   P                  pV P                  P                  VVVVVVVV	V
VR7
      pVe   VP                  MVP                  R,          w  rïV^,          P                  WàP                   P                  VR4      pV P                  V4      pVR,          pV P                   P                  ^8”  d
   VR	,          MRpRpVe   V P                  VV4      pV'       g]   \        ;QJ d    . R VV3 4       F  NK  	  5M! R VV3 4       4      pVe   V3V,           VR,          ,           # VVR,          ,           # \        VVVVP                  VP                  VP                  VP                  VP                  VP                   R7	      # )
a›  
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
    Labels for computing the left-to-right language modeling loss (next word prediction). Indices should be in
    `[-100, 0, ..., config.vocab_size]` (see `input_ids` docstring) Tokens with indices set to `-100` are
    ignored (masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`

Example:

```python
>>> from transformers import AutoTokenizer, ProphetNetForCausalLM
>>> import torch

>>> tokenizer = AutoTokenizer.from_pretrained("microsoft/prophetnet-large-uncased")
>>> model = ProphetNetForCausalLM.from_pretrained("microsoft/prophetnet-large-uncased")
>>> assert model.config.is_decoder, f"{model.__class__} has to be configured as a decoder."
>>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
>>> outputs = model(**inputs)

>>> logits = outputs.logits

>>> # Model can also be used with EncoderDecoder framework
>>> from transformers import BertTokenizer, EncoderDecoderModel, AutoTokenizer
>>> import torch

>>> tokenizer_enc = BertTokenizer.from_pretrained("google-bert/bert-large-uncased")
>>> tokenizer_dec = AutoTokenizer.from_pretrained("microsoft/prophetnet-large-uncased")
>>> model = EncoderDecoderModel.from_encoder_decoder_pretrained(
...     "google-bert/bert-large-uncased", "microsoft/prophetnet-large-uncased"
... )

>>> ARTICLE = (
...     "the us state department said wednesday it had received no "
...     "formal word from bolivia that it was expelling the us ambassador there "
...     "but said the charges made against him are `` baseless ."
... )
>>> input_ids = tokenizer_enc(ARTICLE, return_tensors="pt").input_ids
>>> labels = tokenizer_dec(
...     "us rejects charges against its ambassador in bolivia", return_tensors="pt"
... ).input_ids
>>> outputs = model(input_ids=input_ids, decoder_input_ids=labels[:, :-1], labels=labels[:, 1:])

>>> loss = outputs.loss
```N)
rŸ   rÁ   ri   rÂ  rb   rž  rx  rÝ   rŸ  r   rM  c              3   ó0   "  € T F  qf   K  Vx € K  	  R # 5ir®   r%   r¤  s   & r    r§  Ú0ProphetNetForCausalLM.forward.<locals>.<genexpr>ò  r  r©  r  )	r_   r`   ra   rb   r„   r…   r†   r‡   rg   rP   r  r  )r•   r   r�   rò  r™   r)   r0   r  r  rm   rŠ   rb   r„   r…   r†   r‡   rg   )rž   rŸ   rÁ   ri   rÂ  rb   rž  r  rx  rÝ   rŸ  r   ró   ri  rô   r/   r  r  r`   ra   r_   r  s   &&&&&&&&&&&&,         r    r¿   ÚProphetNetForCausalLM.forwardš  s�  € ðv &1Ò%<‘kÀ$Ç+Á+×BYÑBYˆð —/‘/×)Ñ)ØØ)Ø"7Ø#9Ø+Ø'ØØ/Ø!5Ø#ð *ó 
ˆð :CÒ9N i§o¢oÐTa×TgÑTgÐhjÕTkÑ#ˆ
à$ Q�ZŸ_™_¨Z¿¹×9JÑ9JÈOÐ]_Ó`ÐØŸ™Ð&8Ó9ˆà Õ%ˆØ04·±×0AÑ0AÀAÔ0E�~ eÖ,È4ˆàˆØÒØ×%Ñ% n°fÓ=ˆDçßœÑR¨6°<Ñ*@ÓRŸ™ÑR¨6°<Ñ*@ÓRÓRˆJØ9=Ò9I�D�7˜ZÕ'¨'°"­+Õ5ÐgÈzÐ\cÐdfÕ\gÕOgÐgä,ØØØ)Ø '× 7Ñ 7Ø%×3Ñ3Ø$+×$?Ñ$?Ø"×-Ñ-Ø!(×!9Ñ!9Ø!(×!9Ñ!9ô
ð 
r!   c                ó  € VP                  V P                  P                  VP                  ^ 4      VP                  ^4      4      P	                  V4      p\        V P                  P                  4       F%  pV^ 8”  d   V P                  '       d    MW$VRR3&   K'  	  VP                  ^ ^4      P                  4       p\        P                  P                  VP                  R	VP                  R	4      4      R	\        P                  R7      p\        P                  P                  WdP                  R	4      RR7      pV P                  P                   R8”  dª   VP#                  R	RR7      ) pVP%                  V4      P                  R	4      p	W‰,          pVP'                  4       pV P                  P                   VP                  R	4      ,          p
RV P                  P                   ,
          V,          W¨,          ,           pV# r"  r&  r-  s   &&&&       r    r  Ú#ProphetNetForCausalLM._compute_loss  r5  r!   r>  )NNNNNNNNNNNr?  )rr   rs   rt   ru   r  r²   r”  rš  r   r¿   r  rx   ry   rÈ   rÉ   s   @@r    rA  rA  y  sV   ù‡ € ð 	Ð=Ø3Ð5XðÐ÷
ó ò 7ò8ð ÷dñ dó ðd÷Lô r!   rA  c                   óP   a a€ ] tR tRt oRtRR/tV3R lV 3R lltR tRtVt	V ;t
# )	rE  i  zx
This is a wrapper class, so that [`ProphetNetForCausalLM`] can correctly be loaded from pretrained prophetnet
classes.
rê  ré  c                ó    <€ V ^8„  d   QhRS[ /# r¤   r   )rn   ro   s   "€r    rp   Ú%ProphetNetDecoderWrapper.__annotate__(  s   ø€ ÷ ñ Ñ/ñ r!   c                óÞ   <€ \         SV `  V4       \        P                  ! VP                  VP
                  VP                  R 7      V n        \        V4      V n	        V P                  4        R# )r…  N)r±   r²   r   r†  r‡  r³   r—   rˆ  r´  rò  r�  r´   s   &&€r    r²   Ú!ProphetNetDecoderWrapper.__init__(  sP   ø€ Ü‰Ñ˜Ô ä!Ÿ|š|¨F×,=Ñ,=¸v×?QÑ?QÐ_e×_rÑ_rÔsˆÔÜ(¨Ó0ˆŒð 	�‰Ör!   c                ó&   € V P                   ! V/ VB # r®   )rò  )rž   Úargsró   s   &*,r    r¿   Ú ProphetNetDecoderWrapper.forward1  s   € Ø�|Š|˜TÐ, VÑ,Ð,r!   )rò  rˆ  )rr   rs   rt   ru   rv   r  r²   r¿   rx   ry   rÈ   rÉ   s   @@r    rE  rE    s.   ù‡ € ñð 	)Ð*BðÐ÷ó ÷-ò -r!   rE  rk  )r´  r�  rA  r  rè  rŽ   ):rv   rî  rC   Údataclassesr   r   r   r   Útorch.nnr   Úactivationsr   Úcache_utilsr   r   r	   Ú
generationr
   Úmodeling_layersr   Úmodeling_outputsr   Úmodeling_utilsr   Úutilsr   r   r   r   Úconfiguration_prophetnetr   Ú
get_loggerrr   rÆ  r   r;   rN   rY   r\   r|   r‚   rŠ   rŽ   r†  r©   ÚModulerË   r  r  rY  rm  r�  r´  rè  r  rA  rE  Ú__all__r%   r!   r    Ú<module>rh     s†  ðñ Yã Û Ý !ã ß Ý å !ß CÑ CÝ )Ý 9Ý /Ý -ß QÓ QÝ 6ð 
×	Ò	˜HÓ	%€ôQò7ô, ò6Mñ. ðôð
 ô*? ó *?ó óð*?ñZ ðôð ô(? ;ó (?ó óð(?ñV ðôð
 ô#= ;ó #=ó óð#=ñL ðôð
 ô+= ó +=ó óð+=ð\ ô! ó !ó ð!ô8(- R§\¡\ô (-ôVs2˜"Ÿ)™)ô s2ôl˜BŸI™Iô ô.o/ 2§9¡9ô o/ôd	&Ð7ô &ôRDÐ7ô DñN ðôô
c
Ð1ó c
óð
c
ñL ðôô
hGÐ1ó hGóð
hGðV	 ô|
Ð/ó |
ó ð|
ñ~ ðôô
f:Ð)BÀOó f:óð
f:ñR ðôô
]Ð5°ó ]óð
]ô@-Ð8ô -ò.‚r!   