Ë
    T^(h*� ã                   ó¬  — d Z ddlZddlmZmZmZmZmZ ddlm	Z
 ddlZddlmZ ddlZddlmZmZmZ ddlmZmZ ddlmZ ddlmZ ddlmZmZ dd	lmZ d
dlm Z m!Z!m"Z"m#Z#m$Z$ d
dl%m&Z&m'Z'm(Z(m)Z)m*Z* d
dl+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1  e.jd                  e3«      Z4dZ5dZ6ejn                  Z7dejp                  de9de9dejp                  fd„Z:d^dejp                  de9de9de9dejp                  f
d„Z;dejp                  de9de9dejp                  fd„Z<d^dejp                  de9de9de9dejp                  f
d„Z=de9dejp                  fd „Z>d!ejp                  de9dejp                  fd"„Z?d#ejp                  de9dejp                  fd$„Z@d#ejp                  d%e9deejp                  ejp                  f   fd&„ZAd#ejp                  d%e9dejp                  fd'„ZBd(ejp                  d)ejp                  d*e9dejp                  fd+„ZC G d,„ d-e
jˆ                  «      ZE G d.„ d/e
jˆ                  «      ZF G d0„ d1e
jˆ                  «      ZG G d2„ d3e
jˆ                  «      ZH G d4„ d5e
jˆ                  «      ZI G d6„ d7e
jˆ                  «      ZJ G d8„ d9e
jˆ                  «      ZK G d:„ d;e
jˆ                  «      ZL G d<„ d=e
jˆ                  «      ZM G d>„ d?e
jˆ                  «      ZN G d@„ dAe
jˆ                  «      ZO G dB„ dCe
jˆ                  «      ZP G dD„ dEe
jˆ                  «      ZQ G dF„ dGe
jˆ                  «      ZR G dH„ dIe
jˆ                  «      ZSdJZTdKZUdLZV G dM„ dNe'«      ZWdOZX e,dPeX«       G dQ„ dRe
jˆ                  «      «       ZY G dS„ dTeW«      ZZ e(eZe5e$e6«       dUZ[ e*eZeVe[z   «        e)eZe#e6¬V«        e,dWeX«       G dX„ dYe
jˆ                  «      «       Z\ G dZ„ d[eW«      Z]d\Z^ e*e]eVe^z   «        e)e]e#e6¬V«       g d]¢Z_y)_zFlax LongT5 model.é    N)ÚAnyÚCallableÚListÚOptionalÚTuple)Ú
FrozenDictÚfreezeÚunfreeze)Úcombine_masksÚmake_causal_mask)Úpartitioning)Údot_product_attention_weights)Úflatten_dictÚunflatten_dict)ÚPRNGKeyé   )ÚFlaxBaseModelOutputÚ-FlaxBaseModelOutputWithPastAndCrossAttentionsÚ%FlaxCausalLMOutputWithCrossAttentionsÚFlaxSeq2SeqLMOutputÚFlaxSeq2SeqModelOutput)ÚACT2FNÚFlaxPreTrainedModelÚappend_call_sample_docstringÚ append_replace_return_docstringsÚoverwrite_call_docstring)Úadd_start_docstringsÚ%add_start_docstrings_to_model_forwardÚloggingÚreplace_return_docstringsé   )ÚLongT5Configzgoogle/long-t5-local-baser"   Ú	input_idsÚpad_token_idÚdecoder_start_token_idÚreturnc                 ó  — t        j                  | «      }|j                  dd…dd…f   j                  | dd…dd…f   «      }|j                  dd…df   j                  |«      }t        j                  |dk(  ||«      }|S )z1
    Shift input ids one token to the right.
    Nr!   éÿÿÿÿr   iœÿÿÿ)ÚjnpÚ
zeros_likeÚatÚsetÚwhere)r#   r$   r%   Úshifted_input_idss       úm/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/longt5/modeling_flax_longt5.pyÚshift_tokens_rightr0   :   sƒ   € ô Ÿ™ yÓ1ÐØ)×,Ñ,ªQ°±¨UÑ3×7Ñ7¸	Â!ÀSÀbÀSÀ&Ñ8IÓJÐØ)×,Ñ,ªQ°¨TÑ2×6Ñ6Ð7MÓNÐäŸ	™	Ð"3°tÑ";¸\ÐK\Ó]ÐØÐó    ÚxÚ	block_lenÚaxisÚ	pad_valuec                 óŒ   — | j                   |    |z  }dg| j                  z  }d|f||<   t        j                  | |d|¬«      } | S )zHPad an array so that a sequence length will be a multiple of `block_len`©r   r   r   Úconstant©Ú	pad_widthÚmodeÚconstant_values)ÚshapeÚndimr)   Úpad)r2   r3   r4   r5   Úpad_lenr?   s         r/   Ú_pad_to_multiplerA   F   sL   € à�w‰w�t‰}ˆn˜yÑ(€GØˆ(�Q—V‘VÑ
€CØ�G�€Cˆ�IÜ�‰�˜S zÀ9ÔM€AØ€Hr1   c                 óÞ   — | j                   |   |z  dk7  rt        | ||d¬«      } | j                   |   |z  }| j                   d| ||fz   | j                   |dz   d z   }| j                  |«      S )zÅSplit an input array into blocks of a given `block_len` along the given `axis`. If the dimension length
    is not a multiple of `block_len`, it will be padded first with selected `pad_value`.
    r   )r5   Nr!   )r=   rA   Úreshape)r2   r3   r4   Ú
num_blocksÚoutput_shapes        r/   Ú_split_into_blocksrF   O   sw   € ð
 	‡w�wˆt�}�yÑ  AÒ%Ü˜Q 	¨4¸1Ô=ˆØ—‘˜‘ )Ñ+€JØ—7‘7˜5˜D�> Z°Ð$;Ñ;¸a¿g¹gÀtÈaÁxÀlÐ>SÑS€LØ�9‰9�\Ó"Ð"r1   Ú
block_axisÚsequence_axisc                 ód  — | j                   |   }dg| j                  z  }d||<   t        j                  | |d|¬«      } g }t	        d«      D ]M  }t        dd«      g| j                  z  }t        |||z   «      ||<   t        |«      }|j                  | |   «       ŒO t        j                  ||¬«      S )	z™Concatenate three consecutive blocks for each input block for local attentiont.
    For more information, see: https://arxiv.org/pdf/2112.07916.pdf.
    r7   ©r!   r!   r8   r9   r   r   N©r4   )	r=   r>   r)   r?   ÚrangeÚsliceÚtupleÚappendÚconcatenate)	r2   rG   rH   r5   rD   r?   Úblocks_listÚiÚindicess	            r/   Ú_concatenate_3_blocksrT   [   s³   € ð —‘˜Ñ$€Jàˆ(�Q—V‘VÑ
€CØ€Cˆ
�Oä�‰�˜S zÀ9ÔM€Aà"$€KÜ�1‹Xò 'ˆô ˜˜D“>Ð" Q§V¡VÑ+ˆÜ# A q¨:¡~Ó6ˆ�
ÑÜ˜“.ˆØ×Ñ˜1˜W™:Õ&ð'ô �?‰?˜;¨]Ô;Ð;r1   c                 óˆ   — t        j                  d| z  t         j                  ¬«      }|| |   }|ddd…f   |dd…df   z
  }|S )z:Makes 3-blocked relative position ids for local attention.r   ©ÚdtypeN)r)   ÚarangeÚint32)r3   Úposition_idsÚcenter_position_idsÚrelative_position_idss       r/   Ú"_make_3block_relative_position_idsr]   q   sM   € ä—:‘:˜a )™m´3·9±9Ô=€LØ& y°)°Ð<ÐØ(¨ªq¨Ñ1Ð4GÊÈ4ÈÑ4PÑPÐØ Ð r1   Úlocal_attention_maskc                 óŽ   — t        |«      }t        j                  |«      |k  }|dddd…dd…f   }t        j                  | |«      S )znMask local attention mask to enforce that tokens are not allowed to attend tokens farther than ``local_radius.N)r]   r)   ÚabsÚlogical_and)r^   r3   r\   Úlocality_masks       r/   Ú_mask_local_attention_maskrc   y   sF   € ä>¸yÓIÐÜ—G‘GÐ1Ó2°YÑ>€MØ! $¨ªa²Ð"2Ñ3€MÜ�?‰?Ð/°Ó?Ð?r1   Úattention_maskc                 ó°   — t        | |d¬«      }t        |dd¬«      }|d   }|dddd…f   }t        j                  ||«      }t	        ||«      }|dd…ddf   S )z;Prepare attention mask to be applied for a local attention.r!   rK   é   ©rG   rH   ©.N.N)rF   rT   r)   ra   rc   )rd   r3   Ú_blocked_attention_maskÚ_3blocked_attention_maskr^   s        r/   Ú_get_local_attention_maskrk   �   st   € ô 1°ÀÐQRÔSÐä4Ð5LÐYZÐjkÔlÐà5°iÑ@ÐØ7¸¸TÂ1¸ÑEÐäŸ?™?Ð+BÐD\Ó]ÐÜ5Ð6JÈIÓVÐà¢ 4¨ Ñ-Ð-r1   Úglobal_block_sizec                 ó&  ‡‡
— | j                   dd \  }Š
dt        j                  dt        j                  fˆˆ
fd„}t        j                  | «      ‰z  }t        j
                  |d¬«      |z
  }t        j                  | dk7  d	d
«      }t        j                  t        j                  ||z   d	z
  «      t        j                  d| j                  ¬«      «      }|| z  | dz
  z   } ||«      }‰
‰z  }|dkD  r0t        j                  |j                  d¬«      dd…df   |d¬«      }n#t        j                  |df|j                  ¬«      }t        j
                  t        j                  ||f«      d¬«      dz
  }	t        j                  |	|k  dd«      }	||	fS )a  Obtain the "fixed block" global id corresponding to each input token.

    This implementation is a simlified version of the original Flaxformr implementation adopted from:
    https://github.com/google/flaxformer/blob/main/flaxformer/architectures/longt5/long_attention.py.

    In our scenario, as we use this strategy only for a decoder, orphan tokens, i.e. those tokens which do not make for
    the whole fixed block, are assigned to the preceding block.

    Padding tokens from the original sequence are represented by -1.
    Nrf   Ú	block_idsr&   c                 óÐ   •— t        j                  ‰«      ‰z  ‰dz
  k(  }t        j                  || dk\  «      }|j                  d«      d   }t        j                  | |dz
  «      } | S )Nr!   r   r(   rh   )r)   rX   ra   ÚsumÚminimum)rn   Ú
block_endsÚtrue_block_endsÚfull_blocksrl   Úseq_lens       €€r/   Úhandle_orphan_tokensz:_make_global_fixed_block_ids.<locals>.handle_orphan_tokensž   sf   ø€ Ü—j‘j Ó)Ð,=Ñ=ÐBSÐVWÑBWÑWˆ
ÜŸ/™/¨*°iÀ1±nÓEˆØ%×)Ñ)¨"Ó-¨iÑ8ˆÜ—K‘K 	¨;¸©?Ó;ˆ	ØÐr1   r!   rK   ç        ç      ð?g     @�Àg      ð¿rV   r   r(   )Úrepeatsr4   )r=   ÚnpÚndarrayr)   Ú	ones_likeÚcumsumr-   ÚmaximumÚfloorÚarrayrW   ÚrepeatÚmaxÚzerosÚones)rd   rl   Ú
batch_sizerv   Úfixed_block_maskÚmaskÚglobal_block_idsÚnum_globalsÚ_sequence_block_ids_maxÚglobal_segment_idsru   s    `        @r/   Ú_make_global_fixed_block_idsrŒ   ‘   sƒ  ù€ ð )×.Ñ.¨r°Ð2Ñ€J�ð¬¯
©
ð ´s·{±{ö ô —}‘} ^Ó4Ð7HÑHÐÜ—z‘zÐ"2¸Ô;Ð>NÑNÐÜ�9‰9�^ sÑ*¨C°Ó9€DÜ—{‘{Ü�	‰	�$Ð)Ñ)¨CÑ/Ó0´#·)±)¸DÈ×H\ÑH\Ô2]óÐð )¨>Ñ9¸nÈqÑ>PÑQÐá+Ð,<Ó=ÐØÐ.Ñ.€Kð �Q‚Ü"%§*¡*Ð-=×-AÑ-AÀrÐ-AÓ-JÊ1ÈdÈ7Ñ-SÐ]hÐopÔ"qÑä"%§)¡)¨Z¸¨OÐCS×CYÑCYÔ"ZÐÜŸ™¤C§H¡H¨j¸+Ð-FÓ$GÈbÔQÐTUÑUÐÜŸ™Ð#5Ð9PÑ#PÐRSÐUVÓWÐØÐ/Ð/Ð/r1   c                 ó|   — t        | |«      \  }}|j                  d   }t        j                  |«      }||d   z
  }|S )zBCreate the relative position tensor for local -> global attention.r(   rh   )rŒ   r=   r)   rX   )rd   rl   rn   r‹   Úglobal_seq_lenÚglobal_positionsÚside_relative_positions          r/   Ú _make_side_relative_position_idsr‘   »   sJ   € ä$@ÀÐQbÓ$cÑ!€IÐ!Ø'×-Ñ-¨bÑ1€NÜ—z‘z .Ó1ÐØ-°	¸)Ñ0DÑDÐØ!Ð!r1   Úhidden_statesrn   rŽ   c                 óp   — t         j                  j                  ||«      }t        j                  d| |«      S )zFCompute individual block aggregates by summing over individual blocks.z...nd,...ng->...gd)ÚjaxÚnnÚone_hotr)   Úeinsum)r’   rn   rŽ   Úone_hot_block_idss       r/   Ú_create_global_aggregatesr™   Ä   s.   € ô Ÿ™Ÿ™ y°.ÓAÐÜ�:‰:Ð*¨MÐ;LÓMÐMr1   c                   óÐ   — e Zd ZU eed<   ej                  Zej                  ed<   dZe	ed<   e
j                  j                  j                  Zedej"                  f   ed<   d„ Zd„ Zy	)
ÚFlaxLongT5LayerNormÚhidden_sizerW   g�íµ ÷Æ°>Úeps.Úweight_initc                 ó^   — | j                  d| j                  | j                  f«      | _        y )NÚweight)Úparamrž   rœ   r    ©Úselfs    r/   ÚsetupzFlaxLongT5LayerNorm.setupÒ   s%   € Ø—j‘j ¨4×+;Ñ+;¸d×>NÑ>NÐ=PÓQˆ�r1   c                 óÖ   — t        j                  |j                  d«      d«      j                  dd¬«      }|t        j                  || j
                  z   «      z  }| j                  |z  S )zg
        Construct a layernorm module in the LongT5 style; No bias and no subtraction of mean.
        Úf4rf   r(   T)r4   Úkeepdims)r)   ÚpowerÚastypeÚmeanÚsqrtr�   r    )r£   r’   Úvariances      r/   Ú__call__zFlaxLongT5LayerNorm.__call__Õ   s[   € ô
 —9‘9˜]×1Ñ1°$Ó7¸Ó;×@Ñ@ÀbÐSWÐ@ÓXˆØ%¬¯©°¸D¿H¹HÑ1DÓ(EÑEˆà�{‰{˜]Ñ*Ð*r1   N)Ú__name__Ú
__module__Ú__qualname__ÚintÚ__annotations__r)   Úfloat32rW   r�   Úfloatr”   r•   Úinitializersr„   rž   r   rz   r{   r¤   r­   © r1   r/   r›   r›   Ì   sV   … ØÓØ—{‘{€Eˆ3�9‰9Ó"Ø€CˆÓØ-0¯V©V×-@Ñ-@×-EÑ-E€K�˜#˜rŸz™z˜/Ñ*ÓEòRó+r1   r›   c                   ó\   — e Zd ZU eed<   ej                  Zej                  ed<   d„ Zdd„Z	y)ÚFlaxLongT5DenseActDenseÚconfigrW   c                 óð  — | j                   j                  | j                   j                  dz  z  }| j                   j                  | j                   j                  dz  z  }t	        j
                  | j                   j                  dt        j                  j                  j                  |«      | j                  ¬«      | _
        t	        j
                  | j                   j                  dt        j                  j                  j                  |«      | j                  ¬«      | _        t	        j                  | j                   j                  «      | _        t        | j                   j                      | _        y ©Nç      à¿F©Úuse_biasÚkernel_initrW   )r¹   Úinitializer_factorÚd_modelÚd_ffr•   ÚDenser”   rµ   ÚnormalrW   ÚwiÚwoÚDropoutÚdropout_rateÚdropoutr   Údense_act_fnÚact©r£   Úwi_init_stdÚwo_init_stds      r/   r¤   zFlaxLongT5DenseActDense.setupå   sú   € Ø—k‘k×4Ñ4¸¿¹×8KÑ8KÈTÑ8QÑRˆØ—k‘k×4Ñ4¸¿¹×8HÑ8HÈ$Ñ8NÑOˆä—(‘(Ø�K‰K×ÑØÜŸ™×+Ñ+×2Ñ2°;Ó?Ø—*‘*ô	
ˆŒô —(‘(Ø�K‰K×ÑØÜŸ™×+Ñ+×2Ñ2°;Ó?Ø—*‘*ô	
ˆŒô —z‘z $§+¡+×":Ñ":Ó;ˆŒÜ˜$Ÿ+™+×2Ñ2Ñ3ˆ�r1   c                 ó’   — | j                  |«      }| j                  |«      }| j                  ||¬«      }| j                  |«      }|S ©N©Údeterministic)rÅ   rË   rÉ   rÆ   )r£   r’   rÒ   s      r/   r­   z FlaxLongT5DenseActDense.__call__ø   sD   € ØŸ™ Ó.ˆØŸ™ Ó/ˆØŸ™ ]À-˜ÓPˆØŸ™ Ó.ˆØÐr1   N©T©
r®   r¯   r°   r"   r²   r)   r³   rW   r¤   r­   r¶   r1   r/   r¸   r¸   á   s$   … ØÓØ—{‘{€Eˆ3�9‰9Ó"ò4ô&r1   r¸   c                   óZ   — e Zd ZU eed<   ej                  Zej                  ed<   d„ Zd„ Z	y)ÚFlaxLongT5DenseGatedActDenser¹   rW   c                 ó¶  — | j                   j                  | j                   j                  dz  z  }| j                   j                  | j                   j                  dz  z  }t	        j
                  | j                   j                  dt        j                  j                  j                  |«      | j                  ¬«      | _
        t	        j
                  | j                   j                  dt        j                  j                  j                  |«      | j                  ¬«      | _        t	        j
                  | j                   j                  dt        j                  j                  j                  |«      | j                  ¬«      | _        t	        j                  | j                   j                  «      | _        t         | j                   j"                     | _        y r»   )r¹   rÀ   rÁ   rÂ   r•   rÃ   r”   rµ   rÄ   rW   Úwi_0Úwi_1rÆ   rÇ   rÈ   rÉ   r   rÊ   rË   rÌ   s      r/   r¤   z"FlaxLongT5DenseGatedActDense.setup  s;  € Ø—k‘k×4Ñ4¸¿¹×8KÑ8KÈTÑ8QÑRˆØ—k‘k×4Ñ4¸¿¹×8HÑ8HÈ$Ñ8NÑOˆä—H‘HØ�K‰K×ÑØÜŸ™×+Ñ+×2Ñ2°;Ó?Ø—*‘*ô	
ˆŒ	ô —H‘HØ�K‰K×ÑØÜŸ™×+Ñ+×2Ñ2°;Ó?Ø—*‘*ô	
ˆŒ	ô —(‘(Ø�K‰K×ÑØÜŸ™×+Ñ+×2Ñ2°;Ó?Ø—*‘*ô	
ˆŒô —z‘z $§+¡+×":Ñ":Ó;ˆŒÜ˜$Ÿ+™+×2Ñ2Ñ3ˆ�r1   c                 óº   — | j                  | j                  |«      «      }| j                  |«      }||z  }| j                  ||¬«      }| j	                  |«      }|S rÐ   )rË   rØ   rÙ   rÉ   rÆ   )r£   r’   rÒ   Úhidden_geluÚhidden_linears        r/   r­   z%FlaxLongT5DenseGatedActDense.__call__  sW   € Ø—h‘h˜tŸy™y¨Ó7Ó8ˆØŸ	™	 -Ó0ˆØ# mÑ3ˆØŸ™ ]À-˜ÓPˆØŸ™ Ó.ˆØÐr1   NrÔ   r¶   r1   r/   rÖ   rÖ     s$   … ØÓØ—{‘{€Eˆ3�9‰9Ó"ò4ó2r1   rÖ   c                   ó\   — e Zd ZU eed<   ej                  Zej                  ed<   d„ Zdd„Z	y)ÚFlaxLongT5LayerFFr¹   rW   c                 ó°  — | j                   j                  r't        | j                   | j                  ¬«      | _        n&t        | j                   | j                  ¬«      | _        t        | j                   j                  | j                   j                  | j                  ¬«      | _	        t        j                  | j                   j                  «      | _        y )NrV   ©r�   rW   )r¹   Úis_gated_actrÖ   rW   ÚDenseReluDenser¸   r›   rÁ   Úlayer_norm_epsilonÚ
layer_normr•   rÇ   rÈ   rÉ   r¢   s    r/   r¤   zFlaxLongT5LayerFF.setup,  s‡   € Ø�;‰;×#Ò#Ü">¸t¿{¹{ÐRV×R\ÑR\Ô"]ˆDÕä"9¸$¿+¹+ÈTÏZÉZÔ"XˆDÔä-Ø�K‰K×Ñ T§[¡[×%CÑ%CÈ4Ï:É:ô
ˆŒô —z‘z $§+¡+×":Ñ":Ó;ˆ�r1   c                 óz   — | j                  |«      }| j                  ||¬«      }|| j                  ||¬«      z   }|S rÐ   )rä   râ   rÉ   )r£   r’   rÒ   Úforwarded_statess       r/   r­   zFlaxLongT5LayerFF.__call__7  sG   € ØŸ?™?¨=Ó9ÐØ×.Ñ.Ð/?È}Ð.Ó]ÐØ%¨¯©Ð5EÐUb¨Ó(cÑcˆØÐr1   NrÓ   rÔ   r¶   r1   r/   rÞ   rÞ   (  s$   … ØÓØ—{‘{€Eˆ3�9‰9Ó"ò	<ôr1   rÞ   c                   óÔ   — e Zd ZU eed<   dZeed<   dZeed<   ej                  Z
ej                  ed<   d„ Zedd„«       Zd„ Zd	„ Zd
„ Zej$                  d„ «       Zd„ Z	 	 	 	 	 	 	 dd„Zy)ÚFlaxLongT5Attentionr¹   FÚhas_relative_attention_biasÚcausalrW   c                 ó*  — | j                   j                  | _        | j                   j                  | _        | j                   j                  | _        | j                   j                  | _        | j                   j                  | _        | j                   j                  | _	        | j                  | j
                  z  | _
        | j                   j                  | j                  | j
                  z  dz  z  }| j                   j                  | j                  dz  z  }| j                   j                  | j                  dz  z  }t        j                  | j                  dt        j                  j                  j!                  |«      | j"                  ¬«      | _        t        j                  | j                  dt        j                  j                  j!                  |«      | j"                  ¬«      | _        t        j                  | j                  dt        j                  j                  j!                  |«      | j"                  ¬«      | _        t        j                  | j                  dt        j                  j                  j!                  |«      | j"                  ¬«      | _        | j,                  rdt        j.                  | j                  | j                  t        j                  j                  j!                  |«      | j"                  ¬«      | _        y y )Nr¼   Fr½   ©Úembedding_initrW   )r¹   Úrelative_attention_num_bucketsÚrelative_attention_max_distancerÁ   Úd_kvÚkey_value_proj_dimÚ	num_headsÚn_headsrÈ   rÉ   Ú	inner_dimrÀ   r•   rÃ   r”   rµ   rÄ   rW   ÚqÚkÚvÚoré   ÚEmbedÚrelative_attention_bias©r£   Ú
q_init_stdÚkv_init_stdÚ
o_init_stds       r/   r¤   zFlaxLongT5Attention.setupE  s  € Ø.2¯k©k×.XÑ.XˆÔ+Ø/3¯{©{×/ZÑ/ZˆÔ,Ø—{‘{×*Ñ*ˆŒØ"&§+¡+×"2Ñ"2ˆÔØ—{‘{×,Ñ,ˆŒØ—{‘{×/Ñ/ˆŒØŸ™¨×(?Ñ(?Ñ?ˆŒà—[‘[×3Ñ3¸¿¹È×I`ÑI`Ñ8`ÐeiÑ7iÑjˆ
Ø—k‘k×4Ñ4¸¿¹ÈÑ8LÑMˆØ—[‘[×3Ñ3°t·~±~ÀtÑ7KÑLˆ
ä—‘Ø�N‰NØÜŸ™×+Ñ+×2Ñ2°:Ó>Ø—*‘*ô	
ˆŒô —‘Ø�N‰NØÜŸ™×+Ñ+×2Ñ2°;Ó?Ø—*‘*ô	
ˆŒô —‘Ø�N‰NØÜŸ™×+Ñ+×2Ñ2°;Ó?Ø—*‘*ô	
ˆŒô —‘Ø�L‰LØÜŸ™×+Ñ+×2Ñ2°:Ó>Ø—*‘*ô	
ˆŒð ×+Ò+Ü+-¯8©8Ø×3Ñ3Ø—‘Ü"Ÿv™v×2Ñ2×9Ñ9¸+ÓFØ—j‘jô	,ˆDÕ(ð ,r1   c                 ó˜  — d}|r&|dz  }|| dkD  |z  z  }t        j                  | «      } nt        j                  | d¬«       } |dz  }| |k  }|t        j                  | |z  «      t        j                  ||z  «      z  ||z
  z  z   }t        j                  ||dz
  ¬«      }|t        j                  || |«      z  }|j                  d«      S ©av  
        Adapted from Mesh Tensorflow:
        https://github.com/tensorflow/mesh/blob/0cb87fe07da627bf0b7e60475d59f95ed6b5be3d/mesh_tensorflow/transformer/transformer_layers.py#L593

        Translate relative position to a bucket number for relative attention. The relative position is defined as
        memory_position - query_position, i.e. the distance in tokens from the attending position to the attended-to
        position. If bidirectional=False, then positive relative positions are invalid. We use smaller buckets for
        small absolute relative_position and larger buckets for larger absolute relative_positions. All relative
        positions >=max_distance map to the same bucket. All relative positions <=-max_distance map to the same bucket.
        This should allow for more graceful generalization to longer sequences than the model has been trained on
        r   rf   )Úa_maxr!   Úi4©r)   r`   ÚclipÚlogr-   r©   ©Úrelative_positionÚbidirectionalÚnum_bucketsÚmax_distanceÚrelative_bucketsÚ	max_exactÚis_smallÚrelative_position_if_larges           r/   Ú_relative_position_bucketz-FlaxLongT5Attention._relative_position_buckets  sì   € ð ÐÙØ˜AÑˆKØÐ!2°QÑ!6¸+Ñ EÑEÐÜ #§¡Ð(9Ó :Ñä!$§¡Ð*;À1Ô!EÐ EÐð   1Ñ$ˆ	Ø$ yÑ0ˆð &/Ü�G‰GÐ%¨	Ñ1Ó2´S·W±W¸\ÈIÑ=UÓ5VÑVÐZeÐhqÑZqÑrñ&
Ð"ô &)§X¡XÐ.HÐP[Ð^_ÑP_Ô%`Ð"àœCŸI™I hÐ0AÐC]Ó^Ñ^Ðà×&Ñ& tÓ,Ð,r1   c                 óN  — t        j                  |d¬«      dd…df   }t        j                  |d¬«      ddd…f   }||z
  }| j                  || j                   | j                  | j
                  ¬«      }| j                  |«      }|j                  d«      ddd…dd…dd…f   }|S )ú%Compute binned relative position biasr  rV   N©r  r	  r
  ©rf   r   r!   )r)   rX   r  rê   rî   rï   rú   Ú	transpose)r£   Úquery_lengthÚ
key_lengthÚcontext_positionÚmemory_positionr  Úrelative_position_bucketÚvaluess           r/   Úcompute_biasz FlaxLongT5Attention.compute_bias—  s«   € äŸ:™: l¸$Ô?ÂÀ4ÀÑHÐÜŸ*™* Z°tÔ<¸TÂ1¸WÑEˆà+Ð.>Ñ>ÐØ#'×#AÑ#AØØ#Ÿ{™{˜?Ø×;Ñ;Ø×=Ñ=ð	 $Bó $
Ð ð ×-Ñ-Ð.FÓGˆØ×!Ñ! )Ó,¨T²1²aº¨]Ñ;ˆØˆr1   c                 óp   — |j                  |j                  d d | j                  | j                  fz   «      S ©Nrf   ©rC   r=   ró   rñ   ©r£   r’   s     r/   Ú_split_headsz FlaxLongT5Attention._split_heads¨  ó4   € Ø×$Ñ$ ]×%8Ñ%8¸¸!Ð%<ÀÇÁÈd×NeÑNeÐ?fÑ%fÓgÐgr1   c                 óZ   — |j                  |j                  d d | j                  fz   «      S r  ©rC   r=   rô   r  s     r/   Ú_merge_headsz FlaxLongT5Attention._merge_heads«  s,   € Ø×$Ñ$ ]×%8Ñ%8¸¸!Ð%<ÀÇÁÐ?PÑ%PÓQÐQr1   c                 óR  — | j                  dd«      }| j                  ddt        j                  |j                  |j
                  «      }| j                  ddt        j                  |j                  |j
                  «      }| j                  ddd„ «      }|�r|j                  j                  �^ }	}
}}|j                  }dt        |	«      z  |ddfz   }t        j                  j                  |j                  ||«      }t        j                  j                  |j                  ||«      }||_        ||_        |j                  d   }|j                  |z   |_        t        j                  t        j                  |
«      ||z   k  t        |	«      d||
fz   «      }t        ||«      }|||fS )	a\  
        This function takes projected key, value states from a single input token and concatenates the states to cached
        states from previous steps. This function is slightly adapted from the official Flax repository:
        https://github.com/google/flax/blob/491ce18759622506588784b4fca0e4bf05f8c8cd/flax/linen/attention.py#L252
        ÚcacheÚ
cached_keyÚcached_valueÚcache_indexc                  óL   — t        j                  dt         j                  ¬«      S )Nr   rV   )r)   r€   rY   r¶   r1   r/   ú<lambda>z;FlaxLongT5Attention._concatenate_to_cache.<locals>.<lambda>¹  s   € ÄCÇIÁIÈaÔWZ×W`ÑW`ÔDa€ r1   ©r   r   r!   )Úhas_variableÚvariabler)   rƒ   r=   rW   ÚvalueÚlenr”   ÚlaxÚdynamic_update_sliceÚbroadcast_torX   rN   r   )r£   Úkeyr/  Úqueryrd   Úis_initializedr'  r(  r)  Ú
batch_dimsÚ
max_lengthrò   Údepth_per_headÚ	cur_indexrS   Únum_updated_cache_vectorsÚpad_masks                    r/   Ú_concatenate_to_cachez)FlaxLongT5Attention._concatenate_to_cache®  s|  € ð ×*Ñ*¨7°LÓAˆØ—]‘] 7¨L¼#¿)¹)ÀSÇYÁYÐPS×PYÑPYÓZˆ
Ø—}‘} W¨n¼c¿i¹iÈÏÉÐV[×VaÑVaÓbˆØ—m‘m G¨]Ñ<aÓbˆâØAK×AQÑAQ×AWÑAWÑ>ˆZ˜ Y°à#×)Ñ)ˆIØœS ›_Ñ,°	¸1¸aÐ/@Ñ@ˆGÜ—'‘'×.Ñ.¨z×/?Ñ/?ÀÀgÓNˆCÜ—G‘G×0Ñ0°×1CÑ1CÀUÈGÓTˆEØ"ˆJÔØ!&ˆLÔØ(-¯©°A©Ð%Ø +× 1Ñ 1Ð4MÑ MˆKÔô ×'Ñ'Ü—
‘
˜:Ó&¨Ð5NÑ)NÑNÜ�jÓ! QÐ(AÀ:Ð$NÑNóˆHô +¨8°^ÓDˆNØ�E˜>Ð)Ð)r1   c                 ó  — | j                   xr | j                  dd«      xr | }|j                  d   }|r|n|j                  d   }	| j                  r| j	                  |	|«      }
nG|�t        j                  |«      }
n/t        j                  d| j                  |	|f| j                  ¬«      }
|rR| j                  d   d   j                  d   }t        j                  j                  |
dd|dfd| j                  ||f«      }
|
S )Nr&  r'  r!   rV   r   )rê   r-  r=   ré   r  r)   r*   rƒ   ró   rW   Ú	variablesr”   r1  Údynamic_slice)r£   Ú
key_statesÚquery_statesrd   Ú
init_cacheÚ
seq_lengthÚcausal_attention_mask_shiftÚcache_is_filledr  r  Úposition_biasÚmax_decoder_lengths               r/   Ú_create_position_biasz)FlaxLongT5Attention._create_position_biasÏ  s   € ð Ÿ+™+Òg¨$×*;Ñ*;¸GÀ\Ó*RÒgÐ\fÐXfˆØ×%Ñ% aÑ(ˆ
Ù%4‘z¸,×:LÑ:LÈQÑ:Oˆà×+Ò+Ø ×-Ñ-¨l¸JÓG‰MØÐ'ÜŸN™N¨>Ó:‰MäŸI™I q¨$¯,©,¸ÀjÐ&QÐY]×YcÑYcÔdˆMñ Ø!%§¡°Ñ!8¸Ñ!F×!LÑ!LÈQÑ!OÐÜŸG™G×1Ñ1ØØ�AÐ2°AÐ6Ø�D—L‘L *Ð.@ÐAóˆMð
 Ðr1   Nc	           
      ó"  — |j                   dd \  }	}
| j                  |«      }|€| j                  |«      n| j                  |«      }|€| j                  |«      n| j                  |«      }| j	                  |«      }| j	                  |«      }| j	                  |«      }|t        j                  |j                   d   «      z  }| j                  dd«      r| j                  r| j                  d   d   nd}| j                  rÐt        |d¬	«      }| j                  dd«      rH| j                  d   d   j                   d
   }t        j                  j                  |dd|dfd
d
|
|f«      }t        j                  ||	f|j                   d
d z   «      }t        j                  t        j                  |d¬«      |j                   «      }t!        ||«      }n|�t        j                  |d¬«      }| j                  r,| j                  dd«      s|r| j#                  ||||«      \  }}}|�»t        j$                  | j&                  «      j(                  }t        j                  j+                  |dkD  t        j,                  |j                   d«      j/                  | j&                  «      t        j,                  |j                   |«      j/                  | j&                  «      «      }|€| j1                  |||||
|«      }|�||z   }d}|s | j2                  dkD  r| j5                  d«      }t7        ||||| j2                  d|| j&                  ¬«      }t        j8                  d||«      }| j;                  |«      }| j=                  |«      }||f}|r||fz   }|S )ú€
        Self-attention (if key_value_states is None) or attention over source sentence (provided by key_value_states).
        Nrf   r(   r&  r'  r)  r   ÚboolrV   r!   )éýÿÿÿéþÿÿÿrK   rw   rÉ   T©ÚbiasÚdropout_rngrÈ   Úbroadcast_dropoutrÒ   rW   ú...hqk,...khd->...qhd)r=   rõ   rö   r÷   r   r)   r«   r-  rê   r?  r   r”   r1  r@  r3  Úexpand_dimsr   r=  ÚfinforW   ÚminÚselectÚfullr©   rI  rÉ   Úmake_rngr   r—   r$  rø   )r£   r’   rd   Úkey_value_statesrG  Ú	use_cacheÚoutput_attentionsrÒ   rC  r…   rD  rB  rA  Úvalue_statesrE  Úcausal_attention_maskrH  Ú
mask_valuerQ  Úattn_weightsÚattn_outputÚoutputss                         r/   r­   zFlaxLongT5Attention.__call__ç  s|  € ð "/×!4Ñ!4°R°aÐ!8Ñˆ
�Jð —v‘v˜mÓ,ˆØ.>Ð.F�T—V‘V˜MÔ*ÈDÏFÉFÐScÓLdˆ
Ø0@Ð0H�t—v‘v˜mÔ,ÈdÏfÉfÐUeÓNfˆð ×(Ñ(¨Ó6ˆØ×&Ñ& zÓ2ˆ
Ø×(Ñ(¨Ó6ˆð 	œŸ™ ×!3Ñ!3°BÑ!7Ó8Ñ8ˆð 8<×7HÑ7HÈÐR^Ô7_Ðdh×doÒdoˆD�N‰N˜7Ñ# MÒ2Ðvwð 	$ð �;Š;Ü$4°^È6Ô$RÐ!ð × Ñ  ¨,Ô7Ø%)§^¡^°GÑ%<¸\Ñ%J×%PÑ%PÐQRÑ%SÐ"Ü(+¯©×(=Ñ(=Ø)Ø˜Ð6¸Ð:Ø˜˜:Ð'9Ð:ó)Ð%ô %(×$4Ñ$4Ø%¨
 }Ð7L×7RÑ7RÐSTÐSUÐ7VÑ'Vó%Ð!ô !×-Ñ-Ü—‘ °XÔ>Ð@U×@[Ñ@[óˆNô +¨>Ð;PÓQ‰NØÐ'Ü Ÿ_™_¨^À(ÔKˆNð �;Š;˜D×-Ñ-¨g°|ÔDÉ
Ø7;×7QÑ7QØ˜L¨,¸ó8Ñ4ˆJ˜ nð
 Ð%ÜŸ™ 4§:¡:Ó.×2Ñ2ˆJÜ ŸW™WŸ^™^Ø Ñ"Ü—‘˜×-Ñ-¨sÓ3×:Ñ:¸4¿:¹:ÓFÜ—‘˜×-Ñ-¨zÓ:×AÑAÀ$Ç*Á*ÓMóˆNð Ð à ×6Ñ6Ø˜L¨.¸*ÀjÐRmóˆMð Ð)Ø -°Ñ >�ð ˆÙ §¡°Ò!3ØŸ-™-¨	Ó2ˆKô 5ØØØØ#ØŸ™Ø"Ø'Ø—*‘*ô	
ˆô —j‘jÐ!8¸,ÈÓUˆð ×'Ñ'¨Ó4ˆð —f‘f˜[Ó)ˆà Ð.ˆáØ  Ñ/ˆGàˆr1   ©Té    é€   )NNNFFTF)r®   r¯   r°   r"   r²   ré   rL  rê   r)   r³   rW   r¤   Ústaticmethodr  r  r   r$  r•   Úcompactr=  rI  r­   r¶   r1   r/   rè   rè   ?  s–   … ØÓØ(-Ð Ó-Ø€FˆDÓØ—{‘{€Eˆ3�9‰9Ó"ò,ð\ ò!-ó ð!-òFò"hòRð ‡Z�Zñ*ó ð*ò@ð6 ØØØØØØôqr1   rè   c                   óà   — e Zd ZU eed<   dZeed<   ej                  Z	ej                  ed<   d„ Z
edd„«       Zdefd„Zd	„ Zd
„ Zdedeej&                     dej&                  fd„Z	 	 	 	 	 dd„Zy)ÚFlaxLongT5LocalAttentionr¹   Fré   rW   c                 ór  — | j                   j                  | _        | j                   j                  | _        | j                   j                  | _        | j                   j                  | _        | j                   j                  | _        | j                   j                  | _        | j                  dz   | _	        | j                   j                  | _        | j                  | j
                  z  | _        | j                   j                  | j                  | j
                  z  dz  z  }| j                   j                  | j                  dz  z  }| j                   j                  | j                  dz  z  }t        j                  | j                  dt         j                  j"                  j%                  |«      | j&                  ¬«      | _        t        j                  | j                  dt         j                  j"                  j%                  |«      | j&                  ¬«      | _        t        j                  | j                  dt         j                  j"                  j%                  |«      | j&                  ¬«      | _        t        j                  | j                  dt         j                  j"                  j%                  |«      | j&                  ¬«      | _        | j0                  rYt        j2                  | j                  | j                  t         j                  j"                  j%                  |«      ¬«      | _        y y )Nr!   r¼   Fr½   ©rí   )r¹   rî   rï   rÁ   rð   rñ   rò   ró   Úlocal_radiusr3   rÈ   rÉ   rô   rÀ   r•   rÃ   r”   rµ   rÄ   rW   rõ   rö   r÷   rø   ré   rù   rú   rû   s       r/   r¤   zFlaxLongT5LocalAttention.setup`  s;  € Ø.2¯k©k×.XÑ.XˆÔ+Ø/3¯{©{×/ZÑ/ZˆÔ,Ø—{‘{×*Ñ*ˆŒØ"&§+¡+×"2Ñ"2ˆÔØ—{‘{×,Ñ,ˆŒØ ŸK™K×4Ñ4ˆÔØ×*Ñ*¨QÑ.ˆŒØ—{‘{×/Ñ/ˆŒØŸ™¨×(?Ñ(?Ñ?ˆŒà—[‘[×3Ñ3¸¿¹È×I`ÑI`Ñ8`ÐeiÑ7iÑjˆ
Ø—k‘k×4Ñ4¸¿¹ÈÑ8LÑMˆØ—[‘[×3Ñ3°t·~±~ÀtÑ7KÑLˆ
ä—‘Ø�N‰NØÜŸ™×+Ñ+×2Ñ2°:Ó>Ø—*‘*ô	
ˆŒô —‘Ø�N‰NØÜŸ™×+Ñ+×2Ñ2°;Ó?Ø—*‘*ô	
ˆŒô —‘Ø�N‰NØÜŸ™×+Ñ+×2Ñ2°;Ó?Ø—*‘*ô	
ˆŒô —‘Ø�L‰LØÜŸ™×+Ñ+×2Ñ2°:Ó>Ø—*‘*ô	
ˆŒð ×+Ò+Ü+-¯8©8Ø×3Ñ3Ø—‘Ü"Ÿv™v×2Ñ2×9Ñ9¸+ÓFô,ˆDÕ(ð ,r1   c                 ó˜  — d}|r&|dz  }|| dkD  |z  z  }t        j                  | «      } nt        j                  | d¬«       } |dz  }| |k  }|t        j                  | |z  «      t        j                  ||z  «      z  ||z
  z  z   }t        j                  ||dz
  ¬«      }|t        j                  || |«      z  }|j                  d«      S r   r  r  s           r/   r  z2FlaxLongT5LocalAttention._relative_position_bucket�  óì   € ð ÐÙØ˜AÑˆKØÐ!2°QÑ!6¸+Ñ EÑEÐÜ #§¡Ð(9Ó :Ñä!$§¡Ð*;À1Ô!EÐ EÐð   1Ñ$ˆ	Ø$ yÑ0ˆð &/Ü�G‰GÐ%¨	Ñ1Ó2´S·W±W¸\ÈIÑ=UÓ5VÑVÐZeÐhqÑZqÑrñ&
Ð"ô &)§X¡XÐ.HÐP[Ð^_ÑP_Ô%`Ð"àœCŸI™I hÐ0AÐC]Ó^Ñ^Ðà×&Ñ& tÓ,Ð,r1   Úblock_lengthc                 ó  — t        j                  d|z  d¬«      }|||  }|ddd…f   |dd…df   z
  }| j                  |d| j                  | j                  ¬«      }| j                  |«      }|j                  d«      dddd…dd…dd…f   }|S ©r  r   r  rV   NTr  r  ©r)   rX   r  rî   rï   rú   r  ©r£   ro  r  r  r  r  r  s          r/   r  z%FlaxLongT5LocalAttention.compute_bias´  ó«   € äŸ*™* Q¨Ñ%5¸TÔBˆØ*¨<¸¸ÐFÐà+¨D²!¨GÑ4Ð7GÊÈ4ÈÑ7PÑPÐØ#'×#AÑ#AØØØ×;Ñ;Ø×=Ñ=ð	 $Bó $
Ð ð ×-Ñ-Ð.FÓGˆØ×!Ñ! )Ó,¨T°4ººAºqÐ-@ÑAˆØˆr1   c                 óp   — |j                  |j                  d d | j                  | j                  fz   «      S r  r  r  s     r/   r   z%FlaxLongT5LocalAttention._split_headsÅ  r!  r1   c                 óV   — |j                  |j                  d   d| j                  «      S ©Nr   r(   r#  r  s     r/   r$  z%FlaxLongT5LocalAttention._merge_headsÈ  ó&   € Ø×$Ñ$ ]×%8Ñ%8¸Ñ%;¸RÀÇÁÓPÐPr1   r3   rd   r&   c                 óÜ   — | j                   r| j                  |«      }|S |�t        j                  |«      }|S t        j                  dd| j
                  |d|z  f| j                  ¬«      }|S ©Nr!   r   rV   ©ré   r  r)   r*   rƒ   ró   rW   ©r£   r3   rd   rG  s       r/   rI  z.FlaxLongT5LocalAttention._create_position_biasË  ós   € à×+Ò+Ø ×-Ñ-¨iÓ8ˆMð Ðð Ð'ÜŸN™N¨>Ó:ˆMð Ðô  ŸI™I q¨!¨T¯\©\¸9ÀaÈ)ÁmÐ&TÐ\`×\fÑ\fÔgˆMàÐr1   Nc           
      óN  — |j                   dd \  }}| j                  |«      }	|€| j                  |«      n| j                  |«      }
|€| j                  |«      n| j                  |«      }| j	                  |	«      }	| j	                  |
«      }
| j	                  |«      }t        |	| j                  d¬«      }	t        |
| j                  d¬«      }
t        || j                  d¬«      }t        |
dd¬«      }
t        |dd¬«      }|	t        j                  |	j                   d   «      z  }	|�¨t        || j                  «      }t        j                  j                  |dkD  t        j                  |j                   d«      j                  | j                   «      t        j                  |j                   d	«      j                  | j                   «      «      }|€3| j#                  | j                  |«      }|�||j%                  dd«      z   }d}|s | j&                  dkD  r| j)                  d
«      }t+        |	|
||| j&                  d|| j                   ¬«      }t        j,                  d||«      }| j/                  |«      }|dd…d|…dd…f   }| j1                  |«      }||f}|r||fz   }|S )rK  Nrf   r!   rK   rg   r(   r   rw   ç    _ ÂrÉ   TrO  rS  )r=   rõ   rö   r÷   r   rF   r3   rT   r)   r«   rk   r”   r1  rW  rX  r©   rW   rI  ÚswapaxesrÉ   rY  r   r—   r$  rø   )r£   r’   rd   rZ  rG  r\  rÒ   r…   rD  rB  rA  r]  rQ  r`  ra  rb  s                   r/   r­   z!FlaxLongT5LocalAttention.__call__Ö  s  € ð "/×!4Ñ!4°R°aÐ!8Ñˆ
�Jð —v‘v˜mÓ,ˆØ.>Ð.F�T—V‘V˜MÔ*ÈDÏFÉFÐScÓLdˆ
Ø0@Ð0H�t—v‘v˜mÔ,ÈdÏfÉfÐUeÓNfˆð ×(Ñ(¨Ó6ˆØ×&Ñ& zÓ2ˆ
Ø×(Ñ(¨Ó6ˆô *¨,¸¿¹ÈQÔOˆÜ'¨
°D·N±NÈÔKˆ
Ü)¨,¸¿¹ÈQÔOˆô +¨:À!ÐSTÔUˆ
Ü,¨\ÀaÐWXÔYˆð 	œŸ™ ×!3Ñ!3°BÑ!7Ó8Ñ8ˆàÐ%Ü6°~ÀtÇ~Á~ÓVˆNô !ŸW™WŸ^™^Ø Ñ"Ü—‘˜×-Ñ-¨sÓ3×:Ñ:¸4¿:¹:ÓFÜ—‘˜×-Ñ-¨uÓ5×<Ñ<¸T¿Z¹ZÓHóˆNð Ð à ×6Ñ6°t·~±~À~ÓVˆMàÐ)Ø -°×0GÑ0GÈÈ1Ó0MÑ M�ð ˆÙ §¡°Ò!3ØŸ-™-¨	Ó2ˆKô 5ØØØØ#ØŸ™Ø"Ø'Ø—*‘*ô	
ˆô —j‘jÐ!8¸,ÈÓUˆð ×'Ñ'¨Ó4ˆØ!¢! [ j [²!Ð"3Ñ4ˆð —f‘f˜[Ó)ˆà Ð.ˆáØ  Ñ/ˆGàˆr1   rc  ©NNNFT)r®   r¯   r°   r"   r²   ré   rL  r)   r³   rW   r¤   rf  r  r±   r  r   r$  r   rz   r{   rI  r­   r¶   r1   r/   ri  ri  [  s™   … ØÓØ(-Ð Ó-Ø—{‘{€Eˆ3�9‰9Ó"ò-ð^ ò!-ó ð!-ðF¨ó ò"hòQð	¨sð 	ÀHÈRÏZÉZÑDXð 	Ð]_×]gÑ]gó 	ð ØØØØôUr1   ri  c                   ó0  — e Zd ZU eed<   dZeed<   ej                  Z	ej                  ed<   d„ Z
edd„«       Zdefd„Zd	ej                   d
ej                   dej                   fd„Zd„ Zd„ Zded	eej                      dej                   fd„Z	 	 	 	 	 dd„Zy)Ú"FlaxLongT5TransientGlobalAttentionr¹   Fré   rW   c                 óø  — | j                   j                  | _        | j                   j                  | _        | j                   j                  | _        | j                   j                  | _        | j                   j                  | _        | j                   j                  | _        | j                  dz   | _	        | j                   j                  | _
        | j                   j                  | _        | j                  | j
                  z  | _        | j                   j                  | j                  | j
                  z  dz  z  }| j                   j                  | j                  dz  z  }| j                   j                  | j                  dz  z  }t        j                   | j                  dt"        j                  j$                  j'                  |«      | j(                  ¬«      | _        t        j                   | j                  dt"        j                  j$                  j'                  |«      | j(                  ¬«      | _        t        j                   | j                  dt"        j                  j$                  j'                  |«      | j(                  ¬«      | _        t        j                   | j                  dt"        j                  j$                  j'                  |«      | j(                  ¬«      | _        | j2                  rXt        j4                  | j                  | j                  t"        j                  j$                  j'                  |«      ¬«      | _        | j2                  rXt        j4                  | j                  | j                  t"        j                  j$                  j'                  |«      ¬«      | _        t;        | j                   j                  | j                   j<                  | j(                  ¬«      | _        y )Nr!   r¼   Fr½   rk  rà   ) r¹   rî   rï   rÁ   rð   rñ   rò   ró   rl  r3   rl   rÈ   rÉ   rô   rÀ   r•   rÃ   r”   rµ   rÄ   rW   rõ   rö   r÷   rø   ré   rù   rú   Úglobal_relative_attention_biasr›   rã   Úglobal_input_layer_normrû   s       r/   r¤   z(FlaxLongT5TransientGlobalAttention.setup3  sº  € Ø.2¯k©k×.XÑ.XˆÔ+Ø/3¯{©{×/ZÑ/ZˆÔ,Ø—{‘{×*Ñ*ˆŒØ"&§+¡+×"2Ñ"2ˆÔØ—{‘{×,Ñ,ˆŒØ ŸK™K×4Ñ4ˆÔØ×*Ñ*¨QÑ.ˆŒØ!%§¡×!>Ñ!>ˆÔØ—{‘{×/Ñ/ˆŒØŸ™¨×(?Ñ(?Ñ?ˆŒà—[‘[×3Ñ3¸¿¹È×I`ÑI`Ñ8`ÐeiÑ7iÑjˆ
Ø—k‘k×4Ñ4¸¿¹ÈÑ8LÑMˆØ—[‘[×3Ñ3°t·~±~ÀtÑ7KÑLˆ
ä—‘Ø�N‰NØÜŸ™×+Ñ+×2Ñ2°:Ó>Ø—*‘*ô	
ˆŒô —‘Ø�N‰NØÜŸ™×+Ñ+×2Ñ2°;Ó?Ø—*‘*ô	
ˆŒô —‘Ø�N‰NØÜŸ™×+Ñ+×2Ñ2°;Ó?Ø—*‘*ô	
ˆŒô —‘Ø�L‰LØÜŸ™×+Ñ+×2Ñ2°:Ó>Ø—*‘*ô	
ˆŒð ×+Ò+Ü+-¯8©8Ø×3Ñ3Ø—‘Ü"Ÿv™v×2Ñ2×9Ñ9¸+ÓFô,ˆDÔ(ð ×+Ò+Ü24·(±(Ø×3Ñ3Ø—‘Ü"Ÿv™v×2Ñ2×9Ñ9¸+ÓFô3ˆDÔ/ô
 (;Ø�K‰K×Ñ T§[¡[×%CÑ%CÈ4Ï:É:ô(
ˆÕ$r1   c                 ó˜  — d}|r&|dz  }|| dkD  |z  z  }t        j                  | «      } nt        j                  | d¬«       } |dz  }| |k  }|t        j                  | |z  «      t        j                  ||z  «      z  ||z
  z  z   }t        j                  ||dz
  ¬«      }|t        j                  || |«      z  }|j                  d«      S r   r  r  s           r/   r  z<FlaxLongT5TransientGlobalAttention._relative_position_bucketn  rn  r1   ro  c                 ó  — t        j                  d|z  d¬«      }|||  }|ddd…f   |dd…df   z
  }| j                  |d| j                  | j                  ¬«      }| j                  |«      }|j                  d«      dddd…dd…dd…f   }|S rq  rr  rs  s          r/   r  z/FlaxLongT5TransientGlobalAttention.compute_bias“  rt  r1   rd   r‹   r&   c                 óV  — t        j                  |d   |d d …d d d …f   «      d d …d df   }t        j                  j	                  |dkD  t        j
                  |j                  d«      j                  | j                  «      t        j
                  |j                  d«      j                  | j                  «      «      }t        || j                  «      }| j                  |d| j                  | j                  ¬«      }| j                  |«      }t        j                  |d«      }||z   }|S )	Nrh   .r   rw   r  Tr  )r   r   r!   rf   )r)   Úequalr”   r1  rW  rX  r=   r©   rW   r‘   rl   r  rî   rï   r…  r  )r£   rd   r‹   Úside_attention_maskÚattention_side_biasr�   Úside_relative_position_bucketÚ	side_biass           r/   Úcompute_side_biasz4FlaxLongT5TransientGlobalAttention.compute_side_bias¤  s  € ä!Ÿi™i¨°yÑ(AÐCUÒVWÐY]Ò_`ÐV`ÑCaÓbÒcdÐfjÐloÐcoÑpÐÜ!Ÿg™gŸn™nØ !Ñ#Ü�H‰HÐ(×.Ñ.°Ó4×;Ñ;¸D¿J¹JÓGÜ�H‰HÐ(×.Ñ.°Ó6×=Ñ=¸d¿j¹jÓIó
Ðô "BÀ.ÐRV×RhÑRhÓ!iÐØ(,×(FÑ(FØ"ØØ×;Ñ;Ø×=Ñ=ð	 )Gó )
Ð%ð ×7Ñ7Ð8UÓVˆ	ô —M‘M )¨\Ó:ˆ	à1°IÑ=ÐØ"Ð"r1   c                 óp   — |j                  |j                  d d | j                  | j                  fz   «      S r  r  r  s     r/   r   z/FlaxLongT5TransientGlobalAttention._split_heads½  r!  r1   c                 óV   — |j                  |j                  d   d| j                  «      S rw  r#  r  s     r/   r$  z/FlaxLongT5TransientGlobalAttention._merge_headsÀ  rx  r1   r3   c                 óÜ   — | j                   r| j                  |«      }|S |�t        j                  |«      }|S t        j                  dd| j
                  |d|z  f| j                  ¬«      }|S rz  r{  r|  s       r/   rI  z8FlaxLongT5TransientGlobalAttention._create_position_biasÃ  r}  r1   Nc           
      ó¦  — |j                   dd \  }}t        |�|nt        j                  ||f«      | j                  «      \  }	}
|
j                   d   }t        ||	|«      }| j                  |«      }| j                  |«      }|€| j                  |«      n| j                  |«      }|€| j                  |«      n| j                  |«      }| j                  |«      }| j                  |«      }| j                  |«      }| j                  |«      }| j                  |«      }| j                  |«      }| j                  |«      }t        || j                  d¬«      }t        || j                  d¬«      }t        || j                  d¬«      }t        |dd¬«      }t        |dd¬«      }dg|j                  dz   z  }|j                   d   |d<   t        j                  |dd…ddf   |«      }t        j                  |dd…ddf   |«      }t        j                   ||fd¬«      }t        j                   ||fd¬«      }|t        j"                  |j                   d   «      z  }|�©t%        || j                  «      }t&        j(                  j+                  |dkD  t        j,                  |j                   d	«      j/                  | j0                  «      t        j,                  |j                   d
«      j/                  | j0                  «      «      }nd}|€¦| j3                  | j                  |«      }|�||j5                  dd«      z   }|€t        j                  ||f«      }| j7                  ||
«      }t        || j                  d¬«      }t        j4                  |dd«      }t        j                   ||fd¬«      }d}|s | j8                  d	kD  r| j;                  d«      }t=        ||||| j8                  d|| j0                  ¬«      }t        j>                  d||«      }| jA                  |«      }|dd…d|…dd…f   }| jC                  |«      }||f}|r||fz   }|S )rK  Nrf   r(   r!   rK   rg   .r   rw   r  rN  rÉ   TrO  rS  )"r=   rŒ   r)   r„   rl   r™   r†  rõ   rö   r÷   r   rF   r3   rT   r>   ÚtilerP   r«   rk   r”   r1  rW  rX  r©   rW   rI  r€  r�  rÉ   rY  r   r—   r$  rø   )r£   r’   rd   rZ  rG  r\  rÒ   r…   rD  rn   r‹   Ú_global_seq_lenÚglobal_inputsrB  rA  r]  Úside_key_statesÚside_value_statesÚrepsr^   Úside_position_biasrQ  r`  ra  rb  s                            r/   r­   z+FlaxLongT5TransientGlobalAttention.__call__Î  s2  € ð "/×!4Ñ!4°R°aÐ!8Ñˆ
�Jô )EØ,Ð8‰N¼c¿h¹hÈ
ÐT^ÐG_Ó>`Ø×"Ñ"ó)
Ñ%ˆ	Ð%ð
 -×2Ñ2°2Ñ6ˆÜ1°-ÀÈOÓ\ˆØ×4Ñ4°]ÓCˆð —v‘v˜mÓ,ˆØ.>Ð.F�T—V‘V˜MÔ*ÈDÏFÉFÐScÓLdˆ
Ø0@Ð0H�t—v‘v˜mÔ,ÈdÏfÉfÐUeÓNfˆð ×(Ñ(¨Ó6ˆØ×&Ñ& zÓ2ˆ
Ø×(Ñ(¨Ó6ˆð Ÿ&™& Ó/ˆØ ŸF™F =Ó1Ðð ×+Ñ+¨OÓ<ˆØ ×-Ñ-Ð.?Ó@Ðô *¨,¸¿¹ÈQÔOˆÜ'¨
°D·N±NÈÔKˆ
Ü)¨,¸¿¹ÈQÔOˆô +¨:À!ÐSTÔUˆ
Ü,¨\ÀaÐWXÔYˆð ˆs�o×*Ñ*¨QÑ.Ñ/ˆØ×"Ñ" 1Ñ%ˆˆQ‰ÜŸ(™( ?²1°d¸C°<Ñ#@À$ÓGˆÜŸH™HÐ%6²q¸$À°|Ñ%DÀdÓKÐô —_‘_ j°/Ð%BÈÔKˆ
Ü—‘¨Ð6GÐ'HÈqÔQˆð 	œŸ™ ×!3Ñ!3°BÑ!7Ó8Ñ8ˆàÐ%Ü#<¸^ÈTÏ^É^Ó#\Ð Ü#&§7¡7§>¡>Ø$ qÑ(Ü—‘Ð-×3Ñ3°SÓ9×@Ñ@ÀÇÁÓLÜ—‘Ð-×3Ñ3°UÓ;×BÑBÀ4Ç:Á:ÓNó$Ñ ð $(Ð àÐ à ×6Ñ6°t·~±~À~ÓVˆMØ#Ð/Ø -Ð0D×0MÑ0MÈaÐQRÓ0SÑ S�ð Ð%Ü!$§¡¨:°zÐ*BÓ!C�Ø!%×!7Ñ!7¸ÐHZÓ![ÐÜ!3Ð4FÈÏÉÐ]_Ô!`ÐÜ!$§¡Ð.@À!ÀQÓ!GÐÜŸO™O¨]Ð<NÐ,OÐVXÔYˆMð ˆÙ §¡°Ò!3ØŸ-™-¨	Ó2ˆKô 5ØØØØ#ØŸ™Ø"Ø'Ø—*‘*ô	
ˆô —j‘jÐ!8¸,ÈÓUˆð ×'Ñ'¨Ó4ˆØ!¢! [ j [²!Ð"3Ñ4ˆð —f‘f˜[Ó)ˆà Ð.ˆáØ  Ñ/ˆGàˆr1   rc  r�  )r®   r¯   r°   r"   r²   ré   rL  r)   r³   rW   r¤   rf  r  r±   r  rz   r{   r�  r   r$  r   rI  r­   r¶   r1   r/   rƒ  rƒ  .  sÅ   … ØÓØ(-Ð Ó-Ø—{‘{€Eˆ3�9‰9Ó"ò9
ðv ò!-ó ð!-ðF¨ó ð"#°·
±
ð #ÐPR×PZÑPZð #Ð_a×_iÑ_ió #ò2hòQð	¨sð 	ÀHÈRÏZÉZÑDXð 	Ð]_×]gÑ]gó 	ð ØØØØô}r1   rƒ  c                   ó|   — e Zd ZU dZeed<   dZeed<   ej                  Z
ej                  ed<   d„ Z	 	 	 	 d
defd	„Zy)Ú!FlaxLongT5LayerLocalSelfAttentionz$Local self attention used in encoderr¹   Fré   rW   c                 óL  — t        | j                  | j                  | j                  ¬«      | _        t        | j                  j                  | j                  j                  | j                  ¬«      | _        t        j                  | j                  j                  «      | _        y ©N©ré   rW   rà   )ri  r¹   ré   rW   ÚLocalSelfAttentionr›   rÁ   rã   rä   r•   rÇ   rÈ   rÉ   r¢   s    r/   r¤   z'FlaxLongT5LayerLocalSelfAttention.setupU  sp   € Ü":Ø�K‰K°T×5UÑ5UÐ]a×]gÑ]gô#
ˆÔô .Ø�K‰K×Ñ T§[¡[×%CÑ%CÈ4Ï:É:ô
ˆŒô —z‘z $§+¡+×":Ñ":Ó;ˆ�r1   NÚkwargsc                 ó˜   — | j                  |«      }| j                  |||||¬«      }|| j                  |d   |¬«      z   }|f|dd  z   }	|	S ©N)rd   rG  r\  rÒ   r   rÑ   r!   )rä   r   rÉ   ©
r£   r’   rd   rG  r\  rÒ   r¡  Únormed_hidden_statesÚattention_outputrb  s
             r/   r­   z*FlaxLongT5LayerLocalSelfAttention.__call__^  sr   € ð  $Ÿ™¨}Ó=ÐØ×2Ñ2Ø Ø)Ø'Ø/Ø'ð 3ó 
Ðð &¨¯©Ð5EÀaÑ5HÐXe¨Ó(fÑfˆØ Ð"Ð%5°a°bÐ%9Ñ9ˆØˆr1   ©NNFT©r®   r¯   r°   Ú__doc__r"   r²   ré   rL  r)   r³   rW   r¤   r   r­   r¶   r1   r/   rœ  rœ  N  sJ   … Ù.àÓØ(-Ð Ó-Ø—{‘{€Eˆ3�9‰9Ó"ò<ð ØØØñð ôr1   rœ  c                   ó|   — e Zd ZU dZeed<   dZeed<   ej                  Z
ej                  ed<   d„ Z	 	 	 	 d
defd	„Zy)Ú+FlaxLongT5LayerTransientGlobalSelfAttentionz/Transient-Global self attention used in encoderr¹   Fré   rW   c                 óL  — t        | j                  | j                  | j                  ¬«      | _        t        | j                  j                  | j                  j                  | j                  ¬«      | _        t        j                  | j                  j                  «      | _        y rž  )rƒ  r¹   ré   rW   ÚTransientGlobalSelfAttentionr›   rÁ   rã   rä   r•   rÇ   rÈ   rÉ   r¢   s    r/   r¤   z1FlaxLongT5LayerTransientGlobalSelfAttention.setup{  sp   € Ü,NØ�K‰K°T×5UÑ5UÐ]a×]gÑ]gô-
ˆÔ)ô .Ø�K‰K×Ñ T§[¡[×%CÑ%CÈ4Ï:É:ô
ˆŒô —z‘z $§+¡+×":Ñ":Ó;ˆ�r1   Nr¡  c                 ó˜   — | j                  |«      }| j                  |||||¬«      }|| j                  |d   |¬«      z   }|f|dd  z   }	|	S r£  )rä   r­  rÉ   r¤  s
             r/   r­   z4FlaxLongT5LayerTransientGlobalSelfAttention.__call__„  sr   € ð  $Ÿ™¨}Ó=ÐØ×<Ñ<Ø Ø)Ø'Ø/Ø'ð =ó 
Ðð &¨¯©Ð5EÀaÑ5HÐXe¨Ó(fÑfˆØ Ð"Ð%5°a°bÐ%9Ñ9ˆØˆr1   r§  r¨  r¶   r1   r/   r«  r«  t  sJ   … Ù9àÓØ(-Ð Ó-Ø—{‘{€Eˆ3�9‰9Ó"ò<ð ØØØñð ôr1   r«  c                   ót   — e Zd ZU eed<   dZeed<   ej                  Z	ej                  ed<   d„ Z
	 	 	 	 	 dd„Zy)	ÚFlaxLongT5LayerSelfAttentionr¹   Fré   rW   c                 óv  — t        | j                  | j                  | j                  j                  | j                  ¬«      | _        t        | j                  j                  | j                  j                  | j                  ¬«      | _	        t        j                  | j                  j                  «      | _        y )N©ré   rê   rW   rà   )rè   r¹   ré   rê   rW   ÚSelfAttentionr›   rÁ   rã   rä   r•   rÇ   rÈ   rÉ   r¢   s    r/   r¤   z"FlaxLongT5LayerSelfAttention.setup   s|   € Ü0Ø�K‰KØ(,×(HÑ(HØ—;‘;×%Ñ%Ø—*‘*ô	
ˆÔô .Ø�K‰K×Ñ T§[¡[×%CÑ%CÈ4Ï:É:ô
ˆŒô —z‘z $§+¡+×":Ñ":Ó;ˆ�r1   Nc                 óš   — | j                  |«      }| j                  ||||||¬«      }|| j                  |d   |¬«      z   }|f|dd  z   }	|	S )N©rd   rG  r\  rÒ   rC  r   rÑ   r!   )rä   r³  rÉ   )
r£   r’   rd   rG  r\  rÒ   rC  r¥  r¦  rb  s
             r/   r­   z%FlaxLongT5LayerSelfAttention.__call__¬  su   € ð  $Ÿ™¨}Ó=ÐØ×-Ñ-Ø Ø)Ø'Ø/Ø'Ø!ð .ó 
Ðð &¨¯©Ð5EÀaÑ5HÐXe¨Ó(fÑfˆØ Ð"Ð%5°a°bÐ%9Ñ9ˆØˆr1   )NNFTF©r®   r¯   r°   r"   r²   ré   rL  r)   r³   rW   r¤   r­   r¶   r1   r/   r°  r°  ›  s@   … ØÓØ(-Ð Ó-Ø—{‘{€Eˆ3�9‰9Ó"ò
<ð ØØØØôr1   r°  c                   ód   — e Zd ZU eed<   ej                  Zej                  ed<   d„ Z	 	 	 	 dd„Z	y)ÚFlaxLongT5LayerCrossAttentionr¹   rW   c                 ó:  — t        | j                  dd| j                  ¬«      | _        t	        | j                  j
                  | j                  j                  | j                  ¬«      | _        t        j                  | j                  j                  «      | _        y )NFr²  rà   )rè   r¹   rW   ÚEncDecAttentionr›   rÁ   rã   rä   r•   rÇ   rÈ   rÉ   r¢   s    r/   r¤   z#FlaxLongT5LayerCrossAttention.setupÈ  sl   € Ü2Ø�K‰K°UÀ5ÐPT×PZÑPZô 
ˆÔô .Ø�K‰K×Ñ T§[¡[×%CÑ%CÈ4Ï:É:ô
ˆŒô —z‘z $§+¡+×":Ñ":Ó;ˆ�r1   Nc                 ó˜   — | j                  |«      }| j                  |||||¬«      }|| j                  |d   |¬«      z   }|f|dd  z   }	|	S )N)rd   rZ  rG  r\  r   rÑ   r!   )rä   rº  rÉ   )
r£   r’   rZ  rd   rG  r\  rÒ   r¥  r¦  rb  s
             r/   r­   z&FlaxLongT5LayerCrossAttention.__call__Ñ  sr   € ð  $Ÿ™¨}Ó=ÐØ×/Ñ/Ø Ø)Ø-Ø'Ø/ð 0ó 
Ðð &¨¯©Ð5EÀaÑ5HÐXe¨Ó(fÑfˆØ Ð"Ð%5°a°bÐ%9Ñ9ˆØˆr1   r§  rÔ   r¶   r1   r/   r¸  r¸  Ä  s2   … ØÓØ—{‘{€Eˆ3�9‰9Ó"ò<ð ØØØôr1   r¸  c                   ó|   — e Zd ZU eed<   dZeed<   ej                  Z	ej                  ed<   d„ Z
	 	 	 	 	 	 	 	 	 dd„Zy)	ÚFlaxLongT5Blockr¹   Fré   rW   c                 óº  — | j                   j                  | _        | j                  rt        }nc| j                   j                  dk(  rt        }nC| j                   j                  dk(  rt
        }n#t        d| j                   j                  › d�«      ‚ || j                   | j                  t        d«      | j                  ¬«      f| _
        d}| j                  rD| xj                  t        | j                   t        d«      | j                  ¬«      fz  c_
        |dz  }| xj                  t        | j                   t        |«      | j                  ¬«      fz  c_
        y )	NÚlocalztransient-globalzjFor encoder attention mechanism, either `local` or `transient-global` attention type is expected, but got ú.r   )ré   ÚnamerW   r!   )rÁ  rW   )r¹   rê   r°  Úencoder_attention_typerœ  r«  Ú
ValueErrorré   ÚstrrW   Úlayerr¸  rÞ   )r£   Úattention_layerÚfeed_forward_indexs      r/   r¤   zFlaxLongT5Block.setupì  s  € Ø—k‘k×(Ñ(ˆŒØ�;Š;Ü:‰OØ�[‰[×/Ñ/°7Ò:Ü?‰OØ�[‰[×/Ñ/Ð3EÒEÜI‰OäðØŸ;™;×=Ñ=Ð>¸aðAóð ñ
 Ø—‘Ø,0×,LÑ,LÜ˜“VØ—j‘jô	ð
ˆŒ
ð ÐØ�;Š;Ø�JŠJÔ8¸¿¹Ì3ÈqË6ÐY]×YcÑYcÔdÐfÑf�JØ !Ñ#Ðà�
Š
Ô(¨¯©¼3Ð?QÓ;RÐZ^×ZdÑZdÔeÐgÑgŽ
r1   Nc                 ó  —  | j                   d   |||||	|
¬«      }|d   }|dd  }| j                  xr |d u}|r( | j                   d   ||||||	¬«      }|d   }||dd  z   } | j                   d   ||	¬«      }|f}||z   }|S )Nr   rµ  r!   )rZ  rd   rG  r\  rÒ   r(   rÑ   )rÅ  rê   )r£   r’   rd   rG  Úencoder_hidden_statesÚencoder_attention_maskÚencoder_decoder_position_biasr\  Úreturn_dictrÒ   rC  Úself_attention_outputsÚattention_outputsÚdo_cross_attentionÚcross_attention_outputsrb  s                   r/   r­   zFlaxLongT5Block.__call__	  sÖ   € ð "/ §¡¨A¡ØØ)Ø'Ø/Ø'Ø!ô"
Ðð /¨qÑ1ˆØ2°1°2Ð6Ðà!Ÿ[™[ÒNÐ-BÈ$Ð-NÐÙØ&3 d§j¡j°¡mØØ!6Ø5Ø;Ø"3Ø+ô'Ð#ð 4°AÑ6ˆMð !2Ð4KÈAÈBÐ4OÑ OÐð '˜Ÿ
™
 2™ }ÀMÔRˆà Ð"ˆàÐ-Ñ-ˆð ˆr1   )	NNNNNFTTFr¶  r¶   r1   r/   r½  r½  ç  sN   … ØÓØ(-Ð Ó-Ø—{‘{€Eˆ3�9‰9Ó"òhð@ ØØ"Ø#Ø&*ØØØØô0r1   r½  c                   óv   — e Zd ZU eed<   eed<   ej                  Zej                  ed<   d„ Z		 	 	 	 	 	 	 	 dd„Z
y)ÚFlaxLongT5LayerCollectionr¹   ré   rW   c                 óf   — t        | j                  | j                  | j                  ¬«      | _        y )NrŸ  )r½  r¹   ré   rW   rÅ  r¢   s    r/   r¤   zFlaxLongT5LayerCollection.setupB  s&   € Ü$Ø�K‰K°T×5UÑ5UÐ]a×]gÑ]gô
ˆ�
r1   Nc
                 ó6   — | j                  |||||||||	¬«	      S )N)rd   rG  rÉ  rÊ  rË  r\  rÒ   rC  )rÅ  )
r£   r’   rd   rG  rÉ  rÊ  rË  r\  rÒ   rC  s
             r/   r­   z"FlaxLongT5LayerCollection.__call__G  s5   € ð �z‰zØØ)Ø'Ø"7Ø#9Ø*GØ/Ø'Ø!ð ó 

ð 
	
r1   )NNNNNFTF)r®   r¯   r°   r"   r²   rL  r)   r³   rW   r¤   r­   r¶   r1   r/   rÒ  rÒ  =  sD   … ØÓØ!%Ó%Ø—{‘{€Eˆ3�9‰9Ó"ò
ð ØØ"Ø#Ø&*ØØØô
r1   rÒ  c            	       óŒ   — e Zd ZU eed<   ej                  Zej                  ed<   dZe	ed<   d„ Z
	 	 	 	 	 	 	 	 dde	de	d	e	d
e	fd„Zy)ÚFlaxLongT5BlockCollectionr¹   rW   FÚgradient_checkpointingc                 ó   — | j                   j                  | _        | j                  rnt        t        d¬«      }t        | j                   j                  «      D �cg c].  } || j                   |dk(  | j                  t        |«      ¬«      ‘Œ0 c}| _	        y t        | j                   j                  «      D �cg c]1  }t	        | j                   |dk(  | j                  t        |«      ¬«      ‘Œ3 c}| _	        y c c}w c c}w )N)é   é   é   )Ústatic_argnumsr   )ré   rW   rÁ  )
r¹   rê   r×  ÚrematrÒ  rL   Ú
num_layersrW   rÄ  Úblocks)r£   ÚFlaxLongT5CheckpointLayerrR   s      r/   r¤   zFlaxLongT5BlockCollection.setupf  sÑ   € Ø—k‘k×(Ñ(ˆŒØ×&Ò&Ü(-Ô.GÐXaÔ(bÐ%ô ˜tŸ{™{×5Ñ5Ó6öð ñ *Ø—K‘KØ12°a±ØŸ*™*Ü˜Q›ö	òˆD�Kô" ˜tŸ{™{×5Ñ5Ó6öð ô *Ø—K‘KØ12°a±ØŸ*™*Ü˜Q›ö	òˆD�Kùòùòs   Á3C6Â76C;Nr\  Úoutput_hidden_statesrÒ   rC  c	                 óT  — |rdnd }	|rdnd }
|r| j                   rdnd }d }d }t        | j                  «      D ]`  \  }}|r|	|fz   }	 ||||||||||«	      }|d   }|d   }| j                   r|�	||rdnd   }|sŒB|
|d   fz   }
| j                   sŒX||d   fz   }Œb t        ||	|
|¬«      S )Nr¶   r   r!   r   rf   é   ©Úlast_hidden_stater’   Ú
attentionsÚcross_attentions)rê   Ú	enumeraterß  r   )r£   r’   rd   rÉ  rÊ  r\  rá  rÒ   rC  Úall_hidden_statesÚall_attentionsÚall_cross_attentionsrG  rË  rR   Úlayer_moduleÚlayer_outputss                    r/   r­   z"FlaxLongT5BlockCollection.__call__~  s  € ñ #7™B¸DÐÙ0™°dˆÙ&7¸D¿KºK™rÈdÐØˆØ(,Ð%ä(¨¯©Ó5ò 	V‰OˆAˆ|Ù#Ø$5¸Ð8HÑ$HÐ!á(ØØØØ%Ø&Ø-Ø!ØØó
ˆMð *¨!Ñ,ˆMð
 *¨!Ñ,ˆMà�{Š{Ð4Ð@Ø0=ÑCT¹aÐZ[Ñ0\Ð-â Ø!/°=ÀÑ3CÐ2EÑ!E�Ø—;“;Ø+?À=ÐQRÑCSÐBUÑ+UÑ(ð;	Vô> =Ø+Ø+Ø%Ø1ô	
ð 	
r1   )NNNNFFTF)r®   r¯   r°   r"   r²   r)   r³   rW   r×  rL  r¤   r­   r¶   r1   r/   rÖ  rÖ  a  sq   … ØÓØ—{‘{€Eˆ3�9‰9Ó"Ø#(Ð˜DÓ(òð4 ØØ"Ø#Ø"'Ø%*Ø"Ø ñ6
ð  ð6
ð #ð6
ð ð6
ð ô6
r1   rÖ  c                   ó°   — e Zd ZU eed<   ej                  ed<   ej                  Z	ej                  ed<   dZ
eed<   d„ Z	 	 	 	 	 	 	 	 	 dded	ed
ededef
d„Zy)ÚFlaxLongT5Stackr¹   Úembed_tokensrW   Fr×  c                 ó‚  — | j                   j                  | _        t        | j                   | j                  | j                  ¬«      | _        t        | j                   j                  | j                   j                  | j                  ¬«      | _	        t        j                  | j                   j                  «      | _        y )N©rW   r×  rà   )r¹   rê   rÖ  rW   r×  Úblockr›   rÁ   rã   Úfinal_layer_normr•   rÇ   rÈ   rÉ   r¢   s    r/   r¤   zFlaxLongT5Stack.setup¾  s~   € Ø—k‘k×(Ñ(ˆŒä.Ø�K‰K˜tŸz™zÀ$×B]ÑB]ô
ˆŒ
ô !4Ø�K‰K×Ñ T§[¡[×%CÑ%CÈ4Ï:É:ô!
ˆÔô —z‘z $§+¡+×":Ñ":Ó;ˆ�r1   Nr\  rá  rÌ  rÒ   rC  c
           
      ón  — | j                  |«      }
| j                  |
|¬«      }
| j                  |
|||||||	¬«      }|d   }
| j                  |
«      }
| j                  |
|¬«      }
d }|r|j                  }||
fz   }|s|r
|
|f|dd  z   S |
f|dd  z   S t        |
||j                  |j                  ¬«      S )NrÑ   )rd   rÉ  rÊ  r\  rá  rÒ   rC  r   rf   r!   rä  )rð  rÉ   ró  rô  r’   r   ræ  rç  )r£   r#   rd   rÉ  rÊ  r\  rá  rÌ  rÒ   rC  r’   rb  ré  s                r/   r­   zFlaxLongT5Stack.__call__É  s  € ð ×)Ñ)¨)Ó4ˆØŸ™ ]À-˜ÓPˆà—*‘*ØØ)Ø"7Ø#9Ø/Ø!5Ø'Ø!ð ó 	
ˆð   ™
ˆà×-Ñ-¨mÓ<ˆØŸ™ ]À-˜ÓPˆð !ÐáØ '× 5Ñ 5ÐØ 1°]Ð4DÑ DÐáÙ#à!Ø%ðð ˜A˜B�Kñ ð  ð "Ð# g¨a¨b kÑ1Ð1ä<Ø+Ø+Ø×)Ñ)Ø$×5Ñ5ô	
ð 	
r1   )	NNNNFFTTF)r®   r¯   r°   r"   r²   r•   rù   r)   r³   rW   r×  rL  r¤   r­   r¶   r1   r/   rï  rï  ¸  sˆ   … ØÓØ—(‘(ÓØ—{‘{€Eˆ3�9‰9Ó"Ø#(Ð˜DÓ(ò	<ð ØØ"Ø#Ø"'Ø%*Ø Ø"Ø ñ3
ð  ð3
ð #ð3
ð ð3
ð ð3
ð ô3
r1   rï  aÄ  
    Args:
        input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)`):
            Indices of input sequence tokens in the vocabulary. LongT5 is a model with relative position embeddings so
            you should be able to pad the inputs on both the right and the left.

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

            To know more on how to prepare `input_ids` for pretraining take a look a [LONGT5
            Training](./longt5#training).
        attention_mask (`jnp.ndarray` of shape `(batch_size, sequence_length)`, *optional*):
            Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:

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

            [What are attention masks?](../glossary#attention-mask)
        output_attentions (`bool`, *optional*):
            Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
            tensors for more detail.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
a1
  
    Args:
        decoder_input_ids (`jnp.ndarray` of shape `(batch_size, target_sequence_length)`):
            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)

            For training, `decoder_input_ids` should be provided.
        encoder_outputs (`tuple(tuple(jnp.ndarray)`):
            Tuple consists of (`last_hidden_state`, *optional*: `hidden_states`, *optional*: `attentions`)
            `last_hidden_state` of shape `(batch_size, sequence_length, hidden_size)`, *optional*) is a sequence of
            hidden-states at the output of the last layer of the encoder. Used in the cross-attention of the decoder.
        encoder_attention_mask (`jnp.ndarray` of shape `(batch_size, sequence_length)`, *optional*):
            Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:

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

            [What are attention masks?](../glossary#attention-mask)
        decoder_attention_mask (`jnp.ndarray` 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.

            If you want to change padding behavior, you should modify to your needs. See diagram 1 in [the
            paper](https://arxiv.org/abs/1910.13461) for more information on the default strategy.
        past_key_values (`Dict[str, np.ndarray]`, *optional*, returned by `init_cache` or when passing previous `past_key_values`):
            Dictionary of pre-computed hidden-states (key and values in the attention blocks) that can be used for fast
            auto-regressive decoding. Pre-computed key and value hidden-states are of shape *[batch_size, max_length]*.
        output_attentions (`bool`, *optional*):
            Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
            tensors for more detail.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
a  
    Args:
        input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)`):
            Indices of input sequence tokens in the vocabulary. LongT5 is a model with relative position embeddings so
            you should be able to pad the inputs on both the right and the left.

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

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

            To know more on how to prepare `input_ids` for pretraining take a look a [LONGT5
            Training](./longt5#training).
        attention_mask (`jnp.ndarray` of shape `(batch_size, sequence_length)`, *optional*):
            Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:

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

            [What are attention masks?](../glossary#attention-mask)
        decoder_input_ids (`jnp.ndarray` 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)

            LONGT5 uses the `pad_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`).

            To know more on how to prepare `decoder_input_ids` for pretraining take a look at [LONGT5
            Training](./longt5#training).
        decoder_attention_mask (`jnp.ndarray` 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.
        encoder_outputs (`tuple(tuple(jnp.ndarray)`, *optional*):
            Tuple consists of (`last_hidden_state`, `optional`: *hidden_states*, `optional`: *attentions*)
            `last_hidden_state` of shape `(batch_size, sequence_length, hidden_size)` is a sequence of hidden states at
            the output of the last layer of the encoder. Used in the cross-attention of the decoder.
        past_key_values (`tuple(tuple(jnp.ndarray))` of length `config.n_layers` with each tuple having 4 tensors of shape `(batch_size, num_heads, sequence_length - 1, embed_size_per_head)`):
            Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.

            If `past_key_values` are used, the user can optionally input only the last `decoder_input_ids` (those that
            don't have their past key value states given to this model) of shape `(batch_size, 1)` instead of all
            `decoder_input_ids` of shape `(batch_size, sequence_length)`.


        output_attentions (`bool`, *optional*):
            Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
            tensors for more detail.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
c                   ó  ‡ — e Zd ZU dZeZdZdZej                  e
d<   ddej                  dfded	ee   d
edej                  def
ˆ fd„Zd„ Zd#dej(                  j*                  d	ededefd„Z ee«      	 	 	 	 	 	 	 	 	 d$dej4                  deej4                     dej4                  deej4                     dee   dee   dee   dededefd„«       Zd„ Z ee «       e!e"e¬«      	 	 	 	 	 	 	 d%dej4                  deej4                     dee   dee   dee   dededefd„«       «       Z# ee$«       e!e%e¬«      	 	 	 	 	 	 	 	 	 d$d eej4                     deej4                     d!edee   dee   dee   dededefd"„«       «       Z&ˆ xZ'S )&ÚFlaxLongT5PreTrainedModelz†
    An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
    models.
    ÚtransformerNÚmodule_classrJ   r   Tr¹   Úinput_shapeÚseedrW   Ú_do_initc                 óZ   •—  | j                   d||dœ|¤Ž}t        ‰| �	  ||||||¬«       y )N)r¹   rW   )rú  rû  rW   rü  r¶   )rù  ÚsuperÚ__init__)	r£   r¹   rú  rû  rW   rü  r¡  ÚmoduleÚ	__class__s	           €r/   rÿ  z"FlaxLongT5PreTrainedModel.__init__‹  s=   ø€ ð #�×"Ñ"ÐH¨&¸ÑHÀÑHˆÜ‰Ñ˜ °[ÀtÐSXÐckÐÕlr1   c                 ó^   — | j                  | j                  | j                  d¬«      | _        y )NT)r¹   rW   r×  )rù  r¹   rW   Ú_moduler¢   s    r/   Úenable_gradient_checkpointingz7FlaxLongT5PreTrainedModel.enable_gradient_checkpointing—  s*   € Ø×(Ñ(Ø—;‘;Ø—*‘*Ø#'ð )ó 
ˆ�r1   ÚrngÚparamsr&   c                 ó  — t        j                  |d¬«      }t        j                  |«      }t        j                  |«      }t        j                  |«      }t        j                  j                  |«      \  }}	||	dœ}
| j                  j                  |
||||«      d   }|�dt        t        |«      «      }t        t        |«      «      }| j                  D ]
  }||   ||<   Œ t        «       | _
        t        t        |«      «      S |S )Nr  rV   )r  rÉ   r  )r)   rƒ   r|   r”   ÚrandomÚsplitr   Úinitr   r
   Ú_missing_keysr,   r	   r   )r£   r  rú  r  r#   rd   Údecoder_input_idsÚdecoder_attention_maskÚ
params_rngrQ  ÚrngsÚrandom_paramsÚmissing_keys                r/   Úinit_weightsz&FlaxLongT5PreTrainedModel.init_weightsž  sú   € ä—I‘I˜k°Ô6ˆ	äŸ™ yÓ1ˆÜŸM™M¨)Ó4ÐÜ!$§¡¨yÓ!9Ðä"%§*¡*×"2Ñ"2°3Ó"7Ñˆ
�KØ$°Ñ=ˆàŸ™×(Ñ(ØØØØØ"ó
ð ñˆð ÐÜ(¬°-Ó)@ÓAˆMÜ!¤(¨6Ó"2Ó3ˆFØ#×1Ñ1ò A�Ø&3°KÑ&@��{Ò#ðAä!$£ˆDÔÜœ.¨Ó0Ó1Ð1à Ð r1   r#   rd   r  r  r\  rá  rÌ  ÚtrainrQ  c                 ó8  — |�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }|€t	        d«      ‚|€t        j                  |«      }|€t        j                  |«      }|
�d|
ini }| j                  j                  d|	xs | j                  it        j                  |d¬«      t        j                  |d¬«      t        j                  |d¬«      t        j                  |d¬«      |||| |¬«
      S )NzfMake sure to provide both `input_ids` and `decoder_input_ids`. `decoder_input_ids` is not passed here.rÉ   r  r  rV   )	r#   rd   r  r  r\  rá  rÌ  rÒ   r  )r¹   r\  rá  rÌ  rÃ  r)   r|   r   Úapplyr  r€   )r£   r#   rd   r  r  r\  rá  rÌ  r  r  rQ  r  s               r/   r­   z"FlaxLongT5PreTrainedModel.__call__»  s#  € ð 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×BYÑBYˆàÐ$Üðóð ð Ð!Ü Ÿ]™]¨9Ó5ˆNð "Ð)Ü%(§]¡]Ð3DÓ%EÐ"ð ,7Ð+B�	˜;Ñ'Èˆà�{‰{× Ñ Ø�vÒ, §¡Ð-Ü—i‘i 	°Ô6ÜŸ9™9 ^¸4Ô@Ü!Ÿi™iÐ(9ÀÔFÜ#&§9¡9Ð-CÈ4Ô#PØ/Ø!5Ø#Ø#˜)Øð !ó 
ð 	
r1   c                 ó  — t        j                  ||fd¬«      }t        j                  |«      }d„ }| j                  j	                  t
        j                  j                  d«      |||d   d|¬«      }t        |d   «      S )a+  
        Args:
            batch_size (`int`):
                batch_size used for fast auto-regressive decoding. Defines the batch size of the initialized cache.
            max_length (`int`):
                maximum possible length for auto-regressive decoding. Defines the sequence length of the initialized
                cache.
            encoder_outputs (`Union[FlaxBaseModelOutput, tuple(tuple(jnp.ndarray)]`):
                `encoder_outputs` consists of (`last_hidden_state`, *optional*: `hidden_states`, *optional*:
                `attentions`). `last_hidden_state` of shape `(batch_size, sequence_length, hidden_size)`, *optional*)
                is a sequence of hidden-states at the output of the last layer of the encoder. Used in the
                cross-attention of the decoder.
        r  rV   c                 ó6   — | j                  «       } |||fi |¤ŽS ©N©Ú_get_decoder_module©r   r  r  r¡  Údecoder_modules        r/   Ú_decoder_forwardz>FlaxLongT5PreTrainedModel.init_cache.<locals>._decoder_forwardÿ  ó-   € Ø#×7Ñ7Ó9ˆNÙ!Ø!Ø&ñð ñð r1   r   T)r  r  rÉ  rC  Úmethodr&  )	r)   r„   r|   r   r
  r”   r  r   r
   )r£   r…   r8  Úencoder_outputsr  r  r  Úinit_variabless           r/   rC  z$FlaxLongT5PreTrainedModel.init_cacheí  s‚   € ô  ŸH™H j°*Ð%=ÀTÔJÐÜ!$§¡Ð/@Ó!AÐò	ð Ÿ™×)Ñ)Ü�J‰J×Ñ˜qÓ!Ø/Ø#9Ø"1°!Ñ"4ØØ#ð *ó 
ˆô ˜ wÑ/Ó0Ð0r1   ©Úoutput_typeÚconfig_classc	                 ó¢  — |�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }|€t	        j
                  |«      }i }	|�||	d<   d„ }
| j                  j                  d|xs | j                  it	        j                  |d¬«      t	        j                  |d¬«      |||| |	|
¬«	      S )aÿ  
        Returns:

        Example:

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

        >>> tokenizer = AutoTokenizer.from_pretrained("google-t5/t5-base")
        >>> model = FlaxLongT5ForConditionalGeneration.from_pretrained("google/long-t5-local-base")

        >>> text = "My friends are cool but they eat too many carbs."
        >>> inputs = tokenizer(text, return_tensors="np")
        >>> encoder_outputs = model.encode(**inputs)
        ```rÉ   c                 ó6   — | j                  «       } |||fi |¤ŽS r  )Ú_get_encoder_module)r   r#   rd   r¡  Úencode_modules        r/   Ú_encoder_forwardz:FlaxLongT5PreTrainedModel.encode.<locals>._encoder_forward;  s"   € Ø"×6Ñ6Ó8ˆMÙ  ¨NÑE¸fÑEÐEr1   r  r  rV   )r#   rd   r\  rá  rÌ  rÒ   r  r  )
r¹   r\  rá  rÌ  r)   r|   r   r  r  r€   )r£   r#   rd   r\  rá  rÌ  r  r  rQ  r  r)  s              r/   Úencodez FlaxLongT5PreTrainedModel.encode  sá   € ð8 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×BYÑBYˆàÐ!Ü Ÿ]™]¨9Ó5ˆNð ˆØÐ"Ø)ˆD�‰Oò	Fð �{‰{× Ñ Ø�vÒ, §¡Ð-Ü—i‘i 	°Ô6ÜŸ9™9 ^¸4Ô@Ø/Ø!5Ø#Ø#˜)ØØ#ð !ó 

ð 
	
r1   rÊ  Úpast_key_valuesc                 óö  — |�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }|d   }|€)|j                  dd \  }}t        j                  ||f«      }|j                  \  }}|€t        j                  ||f«      }i }|�||d<   d|
xs | j                  i}|r	||d<   dg}nd}d„ }| j                  j                  |t        j                  |d	¬
«      t        j                  |d	¬
«      |t        j                  |d	¬
«      ||||	 |||¬«      }|�|r|\  }}t        |d   «      |d<   |S |�"|s |\  }}|dd t        |d   «      fz   |dd z   }|S )aG  
        Returns:

        Example:

        ```python
        >>> from transformers import AutoTokenizer, FlaxLongT5ForConditionalGeneration
        >>> import jax.numpy as jnp

        >>> tokenizer = AutoTokenizer.from_pretrained("google-t5/t5-base")
        >>> model = FlaxLongT5ForConditionalGeneration.from_pretrained("google/long-t5-local-base")

        >>> text = "My friends are cool but they eat too many carbs."
        >>> inputs = tokenizer(text, return_tensors="np")
        >>> encoder_outputs = model.encode(**inputs)

        >>> decoder_start_token_id = model.config.decoder_start_token_id
        >>> decoder_input_ids = jnp.ones((inputs.input_ids.shape[0], 1), dtype="i4") * decoder_start_token_id

        >>> outputs = model.decode(decoder_input_ids, encoder_outputs)
        >>> logits = outputs.logits
        ```Nr   rf   rÉ   r  r&  Fc                 ó6   — | j                  «       } |||fi |¤ŽS r  r  r  s        r/   r  z:FlaxLongT5PreTrainedModel.decode.<locals>._decoder_forward�  r  r1   r  rV   ©r  r  rÉ  rÊ  r\  rá  rÌ  rÒ   r  Úmutabler  r+  r!   )r¹   r\  rá  rÌ  r=   r)   r„   r  r   r  r€   r
   )r£   r  r   rÊ  r  r+  r\  rá  rÌ  r  r  rQ  rÉ  r…   Úsequence_lengthr  Úinputsr/  r  rb  Úpasts                        r/   Údecodez FlaxLongT5PreTrainedModel.decodeK  sÏ  € ðL 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×BYÑBYˆà /°Ñ 2ÐØ!Ð)Ø*?×*EÑ*EÀbÀqÐ*IÑ'ˆJ˜Ü%(§X¡X¨z¸?Ð.KÓ%LÐ"à&7×&=Ñ&=Ñ#ˆ
�OØ!Ð)Ü%(§X¡X¨z¸?Ð.KÓ%LÐ"ð ˆØÐ"Ø)ˆD�‰Oà˜FÒ1 d§k¡kÐ2ˆñ
 Ø-ˆF�7‰OØ�i‰GàˆGò	ð —+‘+×#Ñ#ØÜ!Ÿi™iÐ(9ÀÔFÜ#&§9¡9Ð-CÈ4Ô#PØ"7Ü#&§9¡9Ð-CÈ4Ô#PØ/Ø!5Ø#Ø#˜)ØØØ#ð $ó 
ˆð  Ð&©;Ø#‰MˆG�TÜ)1°$°w±-Ó)@ˆGÐ%Ñ&ØˆNØÐ(±Ø#‰MˆG�TØ˜b˜q�k¤X¨d°7©mÓ%<Ð$>Ñ>ÀÈÈÀÑLˆGàˆr1   r  ©	NNNNNNFNN)NNNNFNN)(r®   r¯   r°   r©  r"   r$  Úbase_model_prefixrù  r•   ÚModuler²   r)   r³   r   r±   rW   rL  rÿ  r  r”   r  r   r   r  r   ÚLONGT5_INPUTS_DOCSTRINGr{   r   Údictr­   rC  r   ÚLONGT5_ENCODE_INPUTS_DOCSTRINGr    r   r*  ÚLONGT5_DECODE_INPUTS_DOCSTRINGr   r3  Ú__classcell__)r  s   @r/   r÷  r÷  �  sç  ø… ñð
  €LØ%ÐØ"€L�"—)‘)Ó"ð
 #)ØØŸ;™;Øñ
màð
mð ˜3‘Zð
mð ð	
mð
 �y‰yð
mð õ
mò
ñ! §
¡
× 2Ñ 2ð !Àð !ÐPZð !Ðfpó !ñ: +Ð+BÓCð 15Ø)-Ø8<Ø,0Ø/3Ø&*ØØØ#ñ/
à—;‘;ð/
ð ! §¡Ñ-ð/
ð Ÿ;™;ð	/
ð
 !)¨¯©Ñ 5ð/
ð $ D™>ð/
ð ' t™nð/
ð ˜d‘^ð/
ð ð/
ð ð/
ð ò/
ó Dð/
òb"1ñH Ð8Ó9ÙÐ+>È\ÔZð 15Ø,0Ø/3Ø&*ØØØ#ñ6
à—;‘;ð6
ð ! §¡Ñ-ð6
ð $ D™>ð	6
ð
 ' t™nð6
ð ˜d‘^ð6
ð ð6
ð ð6
ð ò6
ó [ó :ð6
ñp Ð8Ó9ÙÐ+XÐgsÔtð
 9=Ø8<Ø $Ø,0Ø/3Ø&*ØØØ#ñcð !)¨¯©Ñ 5ð	cð
 !)¨¯©Ñ 5ðcð ðcð $ D™>ðcð ' t™nðcð ˜d‘^ðcð ðcð ðcð òcó uó :ôcr1   r÷  a
  
    The LongT5 model was proposed in [LongT5: Efficient Text-To-Text Transformer for Long
    Sequences](https://arxiv.org/abs/2112.07916) by Mandy Guo, Joshua Ainslie, David Uthus, Santiago Ontanon, Jianmo
    Ni, Yun-Hsuan Sung and Yinfei Yang. It's an encoder-decoder transformer pre-trained in a text-to-text denoising
    generative setting. LongT5 model is an extension of T5 model, and it enables using one of the two different
    efficient attention mechanisms - (1) Local attention, or (2) Transient-Global attention.

    This model inherits from [`FlaxPreTrainedModel`]. Check the superclass documentation for the generic methods the
    library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
    etc.)

    This model is also a Flax Linen
    [flax.nn.Module](https://flax.readthedocs.io/en/latest/_autosummary/flax.nn.module.html) subclass. Use it as a
    regular Flax Module and refer to the Flax documentation for all matter related to general usage and behavior.

    Finally, this model supports inherent JAX features such as:

    - [Just-In-Time (JIT) compilation](https://jax.readthedocs.io/en/latest/jax.html#just-in-time-compilation-jit)
    - [Automatic Differentiation](https://jax.readthedocs.io/en/latest/jax.html#automatic-differentiation)
    - [Vectorization](https://jax.readthedocs.io/en/latest/jax.html#vectorization-vmap)
    - [Parallelization](https://jax.readthedocs.io/en/latest/jax.html#parallelization-pmap)

    Parameters:
        config ([`LongT5Config`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~FlaxPreTrainedModel.from_pretrained`] method to load the model weights.
        dtype (`jax.numpy.dtype`, *optional*, defaults to `jax.numpy.float32`):
            The data type of the computation. Can be one of `jax.numpy.float32`, `jax.numpy.float16` (on GPUs) and
            `jax.numpy.bfloat16` (on TPUs).

            This can be used to enable mixed-precision training or half-precision inference on GPUs or TPUs. If
            specified all the computation will be performed with the given `dtype`.

            **Note that this only specifies the dtype of the computation and does not influence the dtype of model
            parameters.**

            If you wish to change the dtype of the model parameters, see [`~FlaxPreTrainedModel.to_fp16`] and
            [`~FlaxPreTrainedModel.to_bf16`].
z_The bare LONGT5 Model transformer outputting raw hidden-stateswithout any specific head on top.c                   óŽ   — e Zd ZU eed<   ej                  Zej                  ed<   dZe	ed<   d„ Z
d„ Zd„ Z	 	 	 	 	 	 	 	 	 dd	e	fd
„Zy)ÚFlaxLongT5Moduler¹   rW   Fr×  c                 ó   — | j                   S r  ©Úencoderr¢   s    r/   r'  z$FlaxLongT5Module._get_encoder_moduleæ  ó   € Ø�|‰|Ðr1   c                 ó   — | j                   S r  ©Údecoderr¢   s    r/   r  z$FlaxLongT5Module._get_decoder_moduleé  rA  r1   c                 ó¶  — t        j                  | j                  j                  | j                  j                  t
        j                   j                  j                  | j                  j                  dz  «      | j                  ¬«      | _
        t        j                  | j                  «      }d|_        t        || j                  | j                  | j                  ¬«      | _        t        j                  | j                  «      }d|_        | j                  j"                  |_        t        || j                  | j                  | j                  ¬«      | _        y )Nrx   rì   F)rð  rW   r×  T)r•   rù   r¹   Ú
vocab_sizerÁ   r”   rµ   rÄ   rÀ   rW   ÚsharedÚcopyÚdeepcopyrê   rï  r×  r@  Únum_decoder_layersrÞ  rD  ©r£   Úencoder_configÚdecoder_configs      r/   r¤   zFlaxLongT5Module.setupì  sñ   € Ü—h‘hØ�K‰K×"Ñ"Ø�K‰K×ÑÜŸ6™6×.Ñ.×5Ñ5°d·k±k×6TÑ6TÐWZÑ6ZÓ[Ø—*‘*ô	
ˆŒô Ÿ™ t§{¡{Ó3ˆØ %ˆÔÜ&ØØŸ™Ø—*‘*Ø#'×#>Ñ#>ô	
ˆŒô Ÿ™ t§{¡{Ó3ˆØ $ˆÔØ$(§K¡K×$BÑ$BˆÔ!Ü&ØØŸ™Ø—*‘*Ø#'×#>Ñ#>ô	
ˆ�r1   NrÒ   c
           
      óp  — |�|n| j                   j                  }| j                  ||||||	¬«      }| j                  |||d   |||||	¬«      }
|s|
|z   S t	        |
j
                  |
j                  |
j                  |
j                  |
j                  |j
                  |j                  |j                  ¬«      S )N©r#   rd   r\  rá  rÌ  rÒ   r   ©r#   rd   rÉ  rÊ  r\  rá  rÌ  rÒ   )rå  r+  Údecoder_hidden_statesÚdecoder_attentionsrç  Úencoder_last_hidden_staterÉ  Úencoder_attentions)
r¹   Úuse_return_dictr@  rD  r   rå  r+  r’   ræ  rç  )r£   r#   rd   r  r  r   r\  rá  rÌ  rÒ   Údecoder_outputss              r/   r­   zFlaxLongT5Module.__call__  sØ   € ð &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆð Ÿ,™,ØØ)Ø/Ø!5Ø#Ø'ð 'ó 
ˆð Ÿ,™,Ø'Ø1Ø"1°!Ñ"4Ø#1Ø/Ø!5Ø#Ø'ð 'ó 	
ˆñ Ø" _Ñ4Ð4ä%Ø-×?Ñ?Ø+×;Ñ;Ø"1×"?Ñ"?Ø.×9Ñ9Ø,×=Ñ=Ø&5×&GÑ&GØ"1×"?Ñ"?Ø.×9Ñ9ô	
ð 		
r1   ©	NNNNNNNNT©r®   r¯   r°   r"   r²   r)   r³   rW   r×  rL  r'  r  r¤   r­   r¶   r1   r/   r=  r=  Ü  sb   … ð ÓØ—{‘{€Eˆ3�9‰9Ó"Ø#(Ð˜DÓ(òòò
ð: ØØØ#ØØØ!ØØ"ñ0
ð ô0
r1   r=  c                   ó   — e Zd ZeZy)ÚFlaxLongT5ModelN)r®   r¯   r°   r=  rù  r¶   r1   r/   rZ  rZ  ;  s   „ Ø#�Lr1   rZ  a”  
    Returns:

    Example:

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

    >>> tokenizer = AutoTokenizer.from_pretrained("google-t5/t5-base")
    >>> model = FlaxLongT5Model.from_pretrained("google/long-t5-local-base")

    >>> input_ids = tokenizer(
    ...     "Studies have been shown that owning a dog is good for you", return_tensors="np"
    ... ).input_ids
    >>> decoder_input_ids = tokenizer("Studies show that", return_tensors="np").input_ids

    >>> # forward pass
    >>> outputs = model(input_ids=input_ids, decoder_input_ids=decoder_input_ids)
    >>> last_hidden_states = outputs.last_hidden_state
    ```
r"  z4LONGT5 Model with a `language modeling` head on top.c                   óŽ   — e Zd ZU eed<   ej                  Zej                  ed<   dZe	ed<   d„ Z
d„ Zd„ Z	 	 	 	 	 	 	 	 	 dd	e	fd
„Zy)Ú(FlaxLongT5ForConditionalGenerationModuler¹   rW   Fr×  c                 ó   — | j                   S r  r?  r¢   s    r/   r'  z<FlaxLongT5ForConditionalGenerationModule._get_encoder_modulec  rA  r1   c                 ó   — | j                   S r  rC  r¢   s    r/   r  z<FlaxLongT5ForConditionalGenerationModule._get_decoder_modulef  rA  r1   c                 óþ  — | j                   j                  | _        t        j                  | j                   j
                  | j                   j                  t        j                  j                  j                  | j                   j                  «      | j                  ¬«      | _        t        j                  | j                   «      }d|_        d|_        d|_        t#        || j                  | j                  | j$                  ¬«      | _        t        j                  | j                   «      }d|_        d|_        | j                   j(                  |_        t#        || j                  | j                  | j$                  ¬«      | _        t        j.                  | j                   j
                  dt        j                  j                  j                  | j                   j                  «      | j                  ¬«      | _        y )Nrì   Frò  Tr½   )r¹   rÁ   Ú	model_dimr•   rù   rF  r”   rµ   rÄ   rÀ   rW   rG  rH  rI  rê   r[  Úis_encoder_decoderrï  r×  r@  rJ  rÞ  rD  rÃ   Úlm_headrK  s      r/   r¤   z.FlaxLongT5ForConditionalGenerationModule.setupi  s[  € ØŸ™×,Ñ,ˆŒä—h‘hØ�K‰K×"Ñ"Ø�K‰K×ÑÜŸ6™6×.Ñ.×5Ñ5°d·k±k×6TÑ6TÓUØ—*‘*ô	
ˆŒô Ÿ™ t§{¡{Ó3ˆØ %ˆÔØ#(ˆÔ Ø,1ˆÔ)Ü&Ø˜DŸK™K¨t¯z©zÐRV×RmÑRmô
ˆŒô Ÿ™ t§{¡{Ó3ˆØ $ˆÔØ,1ˆÔ)Ø$(§K¡K×$BÑ$BˆÔ!Ü&Ø˜DŸK™K¨t¯z©zÐRV×RmÑRmô
ˆŒô —x‘xØ�K‰K×"Ñ"ØÜŸ™×+Ñ+×2Ñ2°4·;±;×3QÑ3QÓRØ—*‘*ô	
ˆ�r1   NrÒ   c
           
      ó¤  — |�|n| j                   j                  }| j                  ||||||	¬«      }|d   }
| j                  |||
|||||	¬«      }|d   }| j                   j                  r|| j
                  dz  z  }| j                   j                  rG| j                  j                  d   d   }| j                  j                  dd|j                  ii|«      }n| j                  |«      }|s|f|dd  z   |z   S t        ||j                  |j                  |j                  |j                  |j                   |j                  |j                  ¬	«      S )
NrO  r   rP  r¼   r  Ú	embeddingÚkernelr!   )Úlogitsr+  rQ  rR  rç  rS  rÉ  rT  )r¹   rU  r@  rD  Útie_word_embeddingsr`  rG  r?  rb  r  ÚTr   r+  r’   ræ  rç  rå  )r£   r#   rd   r  r  r   r\  rá  rÌ  rÒ   r’   rV  Úsequence_outputÚshared_embeddingÚ	lm_logitss                  r/   r­   z1FlaxLongT5ForConditionalGenerationModule.__call__Š  sp  € ð &1Ð%<‘kÀ$Ç+Á+×B]ÑB]ˆð Ÿ,™,ØØ)Ø/Ø!5Ø#Ø'ð 'ó 
ˆð (¨Ñ*ˆð Ÿ,™,Ø'Ø1Ø"/Ø#1Ø/Ø!5Ø#Ø'ð 'ó 	
ˆð *¨!Ñ,ˆà�;‰;×*Ò*ð .°·±ÀÑ1EÑFˆOà�;‰;×*Ò*Ø#Ÿ{™{×4Ñ4°XÑ>¸{ÑKÐØŸ™×*Ñ*¨H°xÐAQ×ASÑASÐ6TÐ+UÐWfÓg‰IàŸ™ _Ó5ˆIáØ�< /°!°"Ð"5Ñ5¸ÑGÐGä"ØØ+×;Ñ;Ø"1×"?Ñ"?Ø.×9Ñ9Ø,×=Ñ=Ø&5×&GÑ&GØ"1×"?Ñ"?Ø.×9Ñ9ô	
ð 		
r1   rW  rX  r¶   r1   r/   r\  r\  \  sc   … ð ÓØ—{‘{€Eˆ3�9‰9Ó"Ø#(Ð˜DÓ(òòò
ðF ØØØ#ØØØ!ØØ"ñ?
ð ô?
r1   r\  c                   ó  — e Zd ZeZ ee«       eee	¬«      	 	 	 	 	 	 	 	 	 dde
ej                     de
ej                     dede
e   de
e   de
e   d	ed
edefd„«       «       Z	 	 	 dde
ej$                     de
ej$                     fd„Zd„ Zy)Ú"FlaxLongT5ForConditionalGenerationr"  NrÊ  r  r+  r\  rá  rÌ  r  r  rQ  c                 óz  ‡ — |�|n‰ j                   j                  }|�|n‰ j                   j                  }|�|n‰ j                   j                  }|d   }|€)|j                  dd \  }}t        j                  ||f«      }|j                  \  }}|€t        j                  ||f«      }i }|�||d<   d|
xs ‰ j                  i}|r	||d<   dg}nd}ˆ fd„}‰ j                  j                  |t        j                  |d	¬
«      t        j                  |d	¬
«      |t        j                  |d	¬
«      ||||	 |||¬«      }|€|\  }}n|\  \  }}}|r.t        ||j                  |j                  |j                  ¬«      }n	|f|dd z   }|�|rt        d   «      |d<   |S |�|s|dd t        d   «      fz   |dd z   }|S )aR  
        Returns:

        Example:

        ```python
        >>> from transformers import AutoTokenizer, FlaxLongT5ForConditionalGeneration
        >>> import jax.numpy as jnp

        >>> tokenizer = AutoTokenizer.from_pretrained("google-t5/t5-base")
        >>> model = FlaxLongT5ForConditionalGeneration.from_pretrained("google/long-t5-local-base")

        >>> text = "summarize: My friends are cool but they eat too many carbs."
        >>> inputs = tokenizer(text, return_tensors="np")
        >>> encoder_outputs = model.encode(**inputs)

        >>> decoder_start_token_id = model.config.decoder_start_token_id
        >>> decoder_input_ids = jnp.ones((inputs.input_ids.shape[0], 1), dtype="i4") * decoder_start_token_id

        >>> outputs = model.decode(decoder_input_ids, encoder_outputs)
        >>> logits = outputs.logits
        ```Nr   rf   rÉ   r  r&  Fc                 ó�  •— | j                  «       } |||fi |¤Ž}|d   }‰	j                  j                  r|‰	j                  j                  dz  z  }‰	j                  j                  rJ| j                  j
                  d   d   }| j                  j                  dd|j                  ii|«      }||fS | j                  |«      }||fS )Nr   r¼   r  rd  re  )	r  r¹   rg  rÁ   rG  r?  rb  r  rh  )
r   r  r  r¡  r  rV  ri  rj  rk  r£   s
            €r/   r  zCFlaxLongT5ForConditionalGeneration.decode.<locals>._decoder_forward	  sÖ   ø€ Ø#×7Ñ7Ó9ˆNÙ,Ø!Ø&ñð ñˆOð .¨aÑ0ˆOà�{‰{×.Ò.ð #2°T·[±[×5HÑ5HÈ$Ñ5NÑ"O�à�{‰{×.Ò.Ø#)§=¡=×#:Ñ#:¸8Ñ#DÀ[Ñ#QÐ Ø"ŸN™N×0Ñ0°(¸XÐGW×GYÑGYÐ<ZÐ1[Ð]lÓm�	ð ˜oÐ-Ð-ð #ŸN™N¨?Ó;�	à˜oÐ-Ð-r1   r  rV   r.  )rf  r’   ræ  rç  r!   r+  )r¹   r\  rá  rÌ  r=   r)   r„   r  r   r  r€   r   r’   ræ  rç  r
   )r£   r  r   rÊ  r  r+  r\  rá  rÌ  r  r  rQ  rÉ  r…   r0  r  r1  r/  r  rb  rk  rV  r2  s   `                      r/   r3  z)FlaxLongT5ForConditionalGeneration.decodeÏ  s  ø€ ðL 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×BYÑBYˆà /°Ñ 2ÐØ!Ð)Ø*?×*EÑ*EÀbÀqÐ*IÑ'ˆJ˜Ü%(§X¡X¨z¸?Ð.KÓ%LÐ"à&7×&=Ñ&=Ñ#ˆ
�OØ!Ð)Ü%(§X¡X¨z¸?Ð.KÓ%LÐ"ð ˆØÐ"Ø)ˆD�‰Oà˜FÒ1 d§k¡kÐ2ˆñ
 Ø-ˆF�7‰OØ�i‰GàˆGô	.ð. —+‘+×#Ñ#ØÜ!Ÿi™iÐ(9ÀÔFÜ#&§9¡9Ð-CÈ4Ô#PØ"7Ü#&§9¡9Ð-CÈ4Ô#PØ/Ø!5Ø#Ø#˜)ØØØ#ð $ó 
ˆð Ð"Ø)0Ñ&ˆI‘à18Ñ.Ñ(ˆY˜¨$áÜ;Ø Ø-×;Ñ;Ø*×5Ñ5Ø!0×!AÑ!Aô	‰Gð !�l _°Q°RÐ%8Ñ8ˆGð Ð&©;Ü)1°$°w±-Ó)@ˆGÐ%Ñ&ØˆNØÐ(±Ø˜b˜q�k¤X¨d°7©mÓ%<Ð$>Ñ>ÀÈÈÀÑLˆGàˆr1   rd   c                 óÌ   — |j                   \  }}| j                  |||«      }	t        j                  ||fd¬«      }
|�!t        j
                  j                  |
|d«      }
|	|||
dœS )Nr  rV   r7   )r+  r   rÊ  r  )r=   rC  r)   r„   r”   r1  r2  )r£   r  r8  rd   r  r   r¡  r…   rD  r+  Úextended_attention_masks              r/   Úprepare_inputs_for_generationz@FlaxLongT5ForConditionalGeneration.prepare_inputs_for_generationR	  sy   € ð "3×!8Ñ!8Ñˆ
�JàŸ/™/¨*°jÀ/ÓRˆô #&§(¡(¨J¸
Ð+CÈ4Ô"PÐØ!Ð-Ü&)§g¡g×&BÑ&BØ'Ð)?Àó'Ð#ð
  /Ø.Ø&4Ø&=ñ	
ð 	
r1   c                 ó$   — |j                   |d<   |S )Nr+  )r+  )r£   Úmodel_outputsÚmodel_kwargss      r/   Úupdate_inputs_for_generationz?FlaxLongT5ForConditionalGeneration.update_inputs_for_generationo	  s   € Ø*7×*GÑ*GˆÐ&Ñ'ØÐr1   r4  )NNN)r®   r¯   r°   r\  rù  r   r:  r    r   r"   r   r)   r{   r8  rL  r   r3  r”   ÚArrayrr  rv  r¶   r1   r/   rm  rm  Ì  s  „ Ø;€LáÐ8Ó9ÙÐ+PÐ_kÔlð
 9=Ø8<Ø $Ø,0Ø/3Ø&*ØØØ#ñð !)¨¯©Ñ 5ð	ð
 !)¨¯©Ñ 5ðð ðð $ D™>ðð ' t™nðð ˜d‘^ðð ðð ðð òó mó :ððJ /3Ø6:Øñ
ð ! §¡Ñ+ð	
ð
 !)¨¯©Ñ 3ó
ó:r1   rm  a¢  
    Returns:

    Example:

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

    >>> tokenizer = AutoTokenizer.from_pretrained("google-t5/t5-base")
    >>> model = FlaxLongT5ForConditionalGeneration.from_pretrained("google/long-t5-local-base")

    >>> ARTICLE_TO_SUMMARIZE = "summarize: My friends are cool but they eat too many carbs."
    >>> inputs = tokenizer([ARTICLE_TO_SUMMARIZE], return_tensors="np")

    >>> # Generate Summary
    >>> summary_ids = model.generate(inputs["input_ids"]).sequences
    >>> print(tokenizer.decode(summary_ids[0], skip_special_tokens=True, clean_up_tokenization_spaces=False))
    ```
)rm  rZ  r÷  r,  )`r©  rH  Útypingr   r   r   r   r   Ú
flax.linenÚlinenr•   r”   Ú	jax.numpyÚnumpyr)   rz   Úflax.core.frozen_dictr   r	   r
   r   r   r   Únn_partitioningÚflax.linen.attentionr   Úflax.traverse_utilr   r   Ú
jax.randomr   Úmodeling_flax_outputsr   r   r   r   r   Úmodeling_flax_utilsr   r   r   r   r   Úutilsr   r   r   r    Úconfiguration_longt5r"   Ú
get_loggerr®   ÚloggerÚ_CHECKPOINT_FOR_DOCÚ_CONFIG_FOR_DOCrÝ  r{   r±   r0   rA   rF   rT   r]   rc   rk   rŒ   r‘   r™   r6  r›   r¸   rÖ   rÞ   rè   ri  rƒ  rœ  r«  r°  r¸  r½  rÒ  rÖ  rï  r9  r:  r7  r÷  ÚLONGT5_START_DOCSTRINGr=  rZ  ÚFLAX_LONGT5_MODEL_DOCSTRINGr\  rm  Ú,FLAX_LONGT5_CONDITIONAL_GENERATION_DOCSTRINGÚ__all__r¶   r1   r/   ú<module>rŽ     s[  ðñ ã ß 7Õ 7å Û 
Ý Û ß >Ñ >ß 6Ý 6Ý >ß ;Ý ÷õ ÷õ ÷ uÓ tÝ .ð 
ˆ×	Ñ	˜HÓ	%€à1Ð Ø €à×Ñ€ð	 #§+¡+ð 	¸Sð 	ÐZ]ð 	Ðbe×bmÑbmó 	ñ˜Ÿ™ð °ð ¸3ð È3ð ÐWZ×WbÑWbó ð	#˜#Ÿ+™+ð 	#°#ð 	#¸Sð 	#ÀSÇ[Á[ó 	#ñ<˜SŸ[™[ð <°cð <È#ð <ÐZ]ð <Ðfi×fqÑfqó <ð,!°#ð !¸#¿+¹+ó !ð@°R·Z±Zð @ÈCð @ÐTW×T_ÑT_ó @ð.¨b¯j©jð .ÀSð .ÈSÏ[É[ó .ð '0°·±ð '0ÐPSð '0ÐX]Ð^a×^iÑ^iÐkm×kuÑkuÐ^uÑXvó '0ðT"°R·Z±Zð "ÐTWð "Ð\^×\fÑ\fó "ðN¨R¯Z©Zð NÀBÇJÁJð NÐ`cð NÐhj×hrÑhró Nô+˜"Ÿ)™)ô +ô*˜bŸi™iô ô@# 2§9¡9ô #ôN˜Ÿ	™	ô ô.Y˜"Ÿ)™)ô YôxP˜rŸy™yô Pôf]¨¯©ô ]ô@	#¨¯	©	ô #ôL#°"·)±)ô #ôN% 2§9¡9ô %ôR  B§I¡Iô  ôFR�b—i‘iô Rôl 
 §	¡	ô  
ôHS
 §	¡	ô S
ônD
�b—i‘iô D
ðN"Ð ð8'"Ð ðT9Ð ôxoÐ 3ô oðd	&Ð ñR ØeØóô
V
�r—y‘yó V
óð
V
ôt$Ð/ô $ñ ˜_Ð.AÐCYÐ[jÔ kðÐ ñ. ˜Ð*AÐD_Ñ*_Ô `Ù   Ð>QÐ`oÕ pñ ÐPÐRhÓiôk
¨r¯y©yó k
ó jðk
ô\eÐ)Bô eðP0Ð ,ñ* Ø&Ð(?ÐBnÑ(nôñ !Ø&Ð4GÐVeõò
 a�r1   