Ë
    S^(hHþ  ã                   óÄ  — d Z ddlZddlZddlmZ ddlmZmZmZ ddl	m
Z ddlZddlm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mZ dd	l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l/m0Z0  e-jb                  e2«      Z3dZ4dZ5dZ6dZ7dZ8dZ9dejt                  de;de;dejt                  fd„Z< G d„ dejz                  «      Z> G d„ dejz                  «      Z? G d „ d!ejz                  «      Z@ G d"„ d#ejz                  «      ZA G d$„ d%ejz                  «      ZB G d&„ d'ejz                  «      ZC G d(„ d)ejz                  «      ZD G d*„ d+ejz                  «      ZE G d,„ d-e&«      ZF e+d.e6«       G d/„ d0eF«      «       ZG e'eGe5e#e4«        G d1„ d2ejz                  «      ZH e+d3e6«       G d4„ d5eF«      «       ZId6ZJ e)eIe7eJz   «        e(eIe"e4¬7«       g d8¢ZKy)9zFlax Blenderbot model.é    N)Úpartial)ÚCallableÚOptionalÚTuple)Ú
FrozenDictÚfreezeÚunfreeze)Úcombine_masksÚmake_causal_mask)Údot_product_attention_weights)Úflatten_dictÚunflatten_dict)Úlax)Ú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é   )ÚBlenderbotConfigr!   z facebook/blenderbot-400M-distilla*  
    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 ([`BlenderbotConfig`]): 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.
aÓ  
    Args:
        input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)`):
            Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
            it.

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

            [What are input IDs?](../glossary#input-ids)
        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)

            For translation and summarization training, `decoder_input_ids` should be provided. If no
            `decoder_input_ids` is provided, the model will create this tensor by shifting the `input_ids` to the right
            for denoising pre-training following the paper.
        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.
        position_ids (`numpy.ndarray` of shape `(batch_size, sequence_length)`, *optional*):
            Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
            config.max_position_embeddings - 1]`.
        decoder_position_ids (`numpy.ndarray` of shape `(batch_size, sequence_length)`, *optional*):
            Indices of positions of each decoder input sequence tokens in the position embeddings. Selected in the
            range `[0, config.max_position_embeddings - 1]`.
        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. Padding will be ignored by default should you provide
            it.

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

            [What are input IDs?](../glossary#input-ids)
        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)
        position_ids (`numpy.ndarray` of shape `(batch_size, sequence_length)`, *optional*):
            Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
            config.max_position_embeddings - 1]`.
        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:
        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 translation and summarization training, `decoder_input_ids` should be provided. If no
            `decoder_input_ids` is provided, the model will create this tensor by shifting the `input_ids` to the right
            for denoising pre-training following the paper.
        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.
        decoder_position_ids (`numpy.ndarray` of shape `(batch_size, sequence_length)`, *optional*):
            Indices of positions of each decoder input sequence tokens in the position embeddings. Selected in the
            range `[0, config.max_position_embeddings - 1]`.
        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.
Ú	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       úu/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/blenderbot/modeling_flax_blenderbot.pyÚshift_tokens_rightr/   Ï   sƒ   € ô Ÿ™ yÓ1ÐØ)×,Ñ,ªQ°±¨UÑ3×7Ñ7¸	Â!ÀSÀbÀSÀ&Ñ8IÓJÐØ)×,Ñ,ªQ°¨TÑ2×6Ñ6Ð7MÓNÐäŸ	™	Ð"3°tÑ";¸\ÐK\Ó]ÐØÐó    c                   óP  — e Zd ZU eed<   eed<   eed<   dZeed<   dZe	ed<   dZ
e	ed	<   ej                  Zej                  ed
<   dd„Zd„ Zd„ Zej$                  d„ «       Z	 	 	 	 ddej(                  deej(                     deej(                     de	de	deej(                     fd„Zy)ÚFlaxBlenderbotAttentionÚconfigÚ	embed_dimÚ	num_headsç        ÚdropoutFÚcausalTÚbiasÚdtyper%   Nc           	      ó  — | j                   | j                  z  | _        | j                  | j                  z  | j                   k7  r&t        d| j                   › d| j                  › d�«      ‚t	        t
        j                  | j                   | j                  | j                  t        j
                  j                  j                  | j                  j                  «      ¬«      } |«        |«        |«       c| _        | _        | _         |«       | _        t        j$                  | j&                  ¬«      | _        | j*                  r>t-        t/        j0                  d| j                  j2                  fd¬«      d¬«      | _        y y )	Nz;embed_dim must be divisible by num_heads (got `embed_dim`: z and `num_heads`: z).©Úuse_biasr:   Úkernel_init©Úrater    Úbool©r:   )r4   r5   Úhead_dimÚ
ValueErrorr   ÚnnÚDenser9   r:   ÚjaxÚinitializersÚnormalr3   Úinit_stdÚq_projÚk_projÚv_projÚout_projÚDropoutr7   Údropout_layerr8   r   r(   ÚonesÚmax_position_embeddingsÚcausal_mask)ÚselfÚdenses     r.   ÚsetupzFlaxBlenderbotAttention.setupå   s  € ØŸ™¨$¯.©.Ñ8ˆŒØ�=‰=˜4Ÿ>™>Ñ)¨T¯^©^Ò;ÜØMÈdÏnÉnÐM]Ø$ T§^¡^Ð$4°Bð8óð ô
 Ü�H‰HØ�N‰NØ—Y‘YØ—*‘*ÜŸ™×+Ñ+×2Ñ2°4·;±;×3GÑ3GÓHô
ˆñ 16³¹»Á%Ã'Ð-ˆŒ�T”[ $¤+Ù›ˆŒäŸZ™Z¨T¯\©\Ô:ˆÔà�;Š;Ü/Ü—‘˜!˜TŸ[™[×@Ñ@ÐAÈÔPÐX^ô ˆDÕð r0   c                 óp   — |j                  |j                  d d | j                  | j                  fz   «      S ©Né   )ÚreshapeÚshaper5   rC   ©rT   Úhidden_statess     r.   Ú_split_headsz$FlaxBlenderbotAttention._split_headsÿ   s5   € Ø×$Ñ$ ]×%8Ñ%8¸¸!Ð%<ÀÇÁÐPT×P]ÑP]Ð?^Ñ%^Ó_Ð_r0   c                 óZ   — |j                  |j                  d d | j                  fz   «      S rX   )rZ   r[   r4   r\   s     r.   Ú_merge_headsz$FlaxBlenderbotAttention._merge_heads  s,   € Ø×$Ñ$ ]×%8Ñ%8¸¸!Ð%<ÀÇÁÐ?PÑ%PÓQÐQr0   c                 ó(  — | 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                  ||«      }t        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   rB   )r(   ÚarrayÚint32© r0   r.   ú<lambda>z?FlaxBlenderbotAttention._concatenate_to_cache.<locals>.<lambda>  s   € ÄCÇIÁIÈaÔWZ×W`ÑW`ÔDa€ r0   )r   r   r    )Úhas_variableÚvariabler(   Úzerosr[   r:   ÚvalueÚlenr   Údynamic_update_sliceÚbroadcast_toÚarangeÚtupler
   )rT   Úkeyrn   ÚqueryÚattention_maskÚis_initializedrc   rd   re   Ú
batch_dimsÚ
max_lengthr5   Údepth_per_headÚ	cur_indexÚindicesÚnum_updated_cache_vectorsÚpad_masks                    r.   Ú_concatenate_to_cachez-FlaxBlenderbotAttention._concatenate_to_cache  sr  € ð ×*Ñ*¨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Ü×*Ñ*¨:×+;Ñ+;¸SÀ'ÓJˆCÜ×,Ñ,¨\×-?Ñ-?ÀÈÓPˆEØ"ˆJÔØ!&ˆLÔØ(-¯©°A©Ð%Ø +× 1Ñ 1Ð4MÑ MˆKÔä×'Ñ'Ü—
‘
˜:Ó&¨Ð5NÑ)NÑNÜ�jÓ! QÐ(AÀ:Ð$NÑNóˆHô +¨8°^ÓDˆNØ�E˜>Ð)Ð)r0   r]   Úkey_value_statesrv   Ú
init_cacheÚdeterministicc                 óÊ  — |du}|j                   d   }| j                  |«      }|r#| j                  |«      }	| j                  |«      }
n"| j                  |«      }	| j                  |«      }
| j	                  |«      }| j	                  |	«      }	| j	                  |
«      }
| j
                  rÍ|j                   d   |	j                   d   }}| j                  dd«      r[| j                  d   d   }| j                  d   d   j                   d   }t        j                  | j                  dd|dfdd||f«      }n| j                  dd…dd…d|…d|…f   }t        j                  ||f|j                   dd z   «      }|�N| j
                  rBt        j                  t        j                  |d¬«      j                   «      }t        ||«      }n(| j
                  r}n|�t        j                  |d¬«      }| j
                  r,| j                  dd«      s|r| j                  |	|
||«      \  }	}
}|�°t        j                   |dkD  t        j"                  |j                   d	«      j%                  | j&                  «      t        j"                  |j                   t        j(                  | j&                  «      j*                  «      j%                  | j&                  «      «      }nd}d}|s | j,                  d	kD  r| j/                  d
«      }t1        ||	||| j,                  d|| j&                  d¬«	      }t        j2                  d||
«      }| j5                  |«      }| j7                  |«      }||fS )z#Input shape: Batch x Time x ChannelNr   r    rb   rc   re   )éýÿÿÿéþÿÿÿ©Úaxisr6   r7   T)r9   Údropout_rngÚdropout_rateÚbroadcast_dropoutr‚   r:   Ú	precisionz...hqk,...khd->...qhd)r[   rK   rL   rM   r^   r8   rk   Ú	variablesr   Údynamic_slicerS   r(   rq   Úexpand_dimsr
   r   ÚselectÚfullÚastyper:   ÚfinfoÚminr7   Úmake_rngr   Úeinsumr`   rN   )rT   r]   r€   rv   r�   r‚   Úis_cross_attentionÚ
batch_sizeÚquery_statesÚ
key_statesÚvalue_statesÚquery_lengthÚ
key_lengthÚ
mask_shiftÚmax_decoder_lengthrS   Úattention_biasrˆ   Úattn_weightsÚattn_outputs                       r.   Ú__call__z FlaxBlenderbotAttention.__call__%  s,  € ð .°TÐ9ÐØ"×(Ñ(¨Ñ+ˆ
ð —{‘{ =Ó1ˆáàŸ™Ð%5Ó6ˆJØŸ;™;Ð'7Ó8‰Lð Ÿ™ ]Ó3ˆJØŸ;™; }Ó5ˆLà×(Ñ(¨Ó6ˆØ×&Ñ& zÓ2ˆ
Ø×(Ñ(¨Ó6ˆð �;Š;Ø'3×'9Ñ'9¸!Ñ'<¸j×>NÑ>NÈqÑ>Q˜*ˆLØ× Ñ  ¨,Ô7Ø!Ÿ^™^¨GÑ4°]ÑC�
Ø%)§^¡^°GÑ%<¸\Ñ%J×%PÑ%PÐQRÑ%SÐ"Ü!×/Ñ/Ø×$Ñ$ q¨!¨Z¸Ð&;¸aÀÀLÐRdÐ=eó‘ð #×.Ñ.ªq²!°]°l°]ÀKÀZÀKÐ/OÑP�Ü×*Ñ*¨;¸¸È×HYÑHYÐZ[ÐZ\ÐH]Ñ8]Ó^ˆKð Ð%¨$¯+ª+Ü ×-Ñ-¬c¯o©o¸nÐS[Ô.\Ð^i×^oÑ^oÓpˆNÜ*¨>¸;ÓG‰NØ�[Š[Ø(‰NØÐ'Ü Ÿ_™_¨^À(ÔKˆNð �;Š;˜D×-Ñ-¨g°|ÔDÉ
Ø7;×7QÑ7QØ˜L¨,¸ó8Ñ4ˆJ˜ nð
 Ð%ä ŸZ™ZØ Ñ"Ü—‘˜×-Ñ-¨sÓ3×:Ñ:¸4¿:¹:ÓFÜ—‘˜×-Ñ-¬s¯y©y¸¿¹Ó/D×/HÑ/HÓI×PÑPÐQU×Q[ÑQ[Ó\ó‰Nð "ˆNàˆÙ §¡°Ò!3ØŸ-™-¨	Ó2ˆKä4ØØØØ#ØŸ™Ø"Ø'Ø—*‘*Øô

ˆô —j‘jÐ!8¸,ÈÓUˆØ×'Ñ'¨Ó4ˆØ—m‘m KÓ0ˆà˜LÐ(Ð(r0   ©r%   N)NNFT)Ú__name__Ú
__module__Ú__qualname__r!   Ú__annotations__Úintr7   Úfloatr8   rA   r9   r(   Úfloat32r:   rV   r^   r`   rE   Úcompactr   Úndarrayr   r   r¢   ri   r0   r.   r2   r2   Ü   sß   … ØÓØƒNØƒNØ€GˆUÓØ€FˆDÓØ€Dˆ$ÓØ—{‘{€Eˆ3�9‰9Ó"óò4`òRð ‡Z�Zñ*ó ð*ðD 37Ø04Ø Ø"ñ[)à—{‘{ð[)ð # 3§;¡;Ñ/ð[)ð ! §¡Ñ-ð	[)ð
 ð[)ð ð[)ð 
ˆs�{‰{Ñ	ô[)r0   r2   c                   óº   — e Zd ZU eed<   ej                  Zej                  ed<   dd„Z	 	 ddej                  dej                  de
d	e
deej                     f
d
„Zy)ÚFlaxBlenderbotEncoderLayerr3   r:   r%   Nc                 óL  — | j                   j                  | _        t        | j                   | j                  | j                   j                  | j                   j
                  | j                  ¬«      | _        t        j                  | j                  d¬«      | _
        t        j                  | j                   j                  ¬«      | _        t        | j                   j                     | _        t        j                  | j                   j"                  ¬«      | _        t        j&                  | j                   j(                  | j                  t*        j                  j,                  j/                  | j                   j0                  «      ¬«      | _        t        j&                  | j                  | j                  t*        j                  j,                  j/                  | j                   j0                  «      ¬«      | _        t        j                  | j                  d¬«      | _        y )N©r3   r4   r5   r7   r:   çñhãˆµøä>©r:   Úepsilonr?   ©r:   r>   )r3   Úd_modelr4   r2   Úencoder_attention_headsÚattention_dropoutr:   Ú	self_attnrE   Ú	LayerNormÚself_attn_layer_normrO   r7   rP   r   Úactivation_functionÚactivation_fnÚactivation_dropoutÚactivation_dropout_layerrF   Úencoder_ffn_dimrG   rH   rI   rJ   Úfc1Úfc2Úfinal_layer_norm©rT   s    r.   rV   z FlaxBlenderbotEncoderLayer.setupˆ  sV  € ØŸ™×,Ñ,ˆŒÜ0Ø—;‘;Ø—n‘nØ—k‘k×9Ñ9Ø—K‘K×1Ñ1Ø—*‘*ô
ˆŒô %'§L¡L°t·z±zÈ5Ô$QˆÔ!ÜŸZ™Z¨T¯[©[×-@Ñ-@ÔAˆÔÜ# D§K¡K×$CÑ$CÑDˆÔÜ(*¯
©
¸¿¹×8VÑ8VÔ(WˆÔ%Ü—8‘8Ø�K‰K×'Ñ'Ø—*‘*ÜŸ™×+Ñ+×2Ñ2°4·;±;×3GÑ3GÓHô
ˆŒô
 —8‘8Ø�N‰N $§*¡*¼#¿&¹&×:MÑ:M×:TÑ:TÐUY×U`ÑU`×UiÑUiÓ:jô
ˆŒô !#§¡°4·:±:ÀuÔ MˆÕr0   r]   rv   Úoutput_attentionsr‚   c                 ó|  — |}| j                  |«      }| j                  ||¬«      \  }}| j                  ||¬«      }||z   }|}| j                  |«      }| j	                  | j                  |«      «      }| j                  ||¬«      }| j                  |«      }| j                  ||¬«      }||z   }|f}|r||fz  }|S )N)r]   rv   ©r‚   )rº   r¸   rP   rÂ   r¼   rÀ   r¾   rÁ   )rT   r]   rv   rÄ   r‚   Úresidualr    Úoutputss           r.   r¢   z#FlaxBlenderbotEncoderLayer.__call__Ÿ  sÝ   € ð !ˆØ×1Ñ1°-Ó@ˆØ&*§n¡nÀ=Ðao nÓ&pÑ#ˆ�|Ø×*Ñ*¨=ÈÐ*ÓVˆØ  =Ñ0ˆà ˆØ×-Ñ-¨mÓ<ˆØ×*Ñ*¨4¯8©8°MÓ+BÓCˆØ×5Ñ5°mÐS`Ð5ÓaˆØŸ™ Ó/ˆØ×*Ñ*¨=ÈÐ*ÓVˆØ  =Ñ0ˆà Ð"ˆáØ˜�Ñ&ˆGàˆr0   r£   )TT)r¤   r¥   r¦   r!   r§   r(   rª   r:   rV   r¬   rA   r   r¢   ri   r0   r.   r®   r®   „  sn   … ØÓØ—{‘{€Eˆ3�9‰9Ó"óNð6 #'Ø"ñà—{‘{ðð Ÿ™ðð  ð	ð
 ðð 
ˆs�{‰{Ñ	ôr0   r®   c            	       óv   — e Zd ZU eed<   ej                  Zej                  ed<   d„ Z	 	 	 	 d
de	de	de	de	fd„Z
y	)Ú$FlaxBlenderbotEncoderLayerCollectionr3   r:   c           	      óú   — t        | j                  j                  «      D �cg c]-  }t        | j                  t	        |«      | j
                  ¬«      ‘Œ/ c}| _        | j                  j                  | _        y c c}w ©N)Únamer:   )	Úranger3   Úencoder_layersr®   Ústrr:   ÚlayersÚencoder_layerdropÚ	layerdrop©rT   Úis     r.   rV   z*FlaxBlenderbotEncoderLayerCollection.setupÁ  óZ   € ô ˜4Ÿ;™;×5Ñ5Ó6ö
àô ' t§{¡{¼¸Q»ÀtÇzÁzÖRò
ˆŒð Ÿ™×6Ñ6ˆ�ùò	
ó   ¢2A8r‚   rÄ   Úoutput_hidden_statesÚreturn_dictc                 ó6  — |rdnd }|rdnd }| j                   D ]P  }	|r||fz   }t        j                  dd«      }
|s|
| j                  k  rd}n |	||||«      }|d   }|sŒH||d   fz   }ŒR |r||fz  }|||f}|st	        d„ |D «       «      S t        |||¬«      S )Nri   r   r    )NNc              3   ó&   K  — | ]	  }|€Œ|–— Œ y ­w©Nri   ©Ú.0Úvs     r.   ú	<genexpr>z@FlaxBlenderbotEncoderLayerCollection.__call__.<locals>.<genexpr>ì  ó   è ø€ Ò=˜q¨q©}œÑ=ùó   ‚Š©Úlast_hidden_stater]   Ú
attentions)rÑ   ÚrandomÚuniformrÓ   rs   r   )rT   r]   rv   r‚   rÄ   rØ   rÙ   Úall_attentionsÚall_hidden_statesÚencoder_layerÚdropout_probabilityÚlayer_outputsrÈ   s                r.   r¢   z-FlaxBlenderbotEncoderLayerCollection.__call__È  sã   € ñ  1™°dˆÙ"6™B¸DÐà!Ÿ[™[ò 	FˆMÙ#Ø$5¸Ð8HÑ$HÐ!ä"(§.¡.°°AÓ"6ÐÙ Ð&9¸D¿N¹NÒ&JØ ,‘á -Ø!Ø"Ø%Ø!ó	!�ð *¨!Ñ,ˆMÚ Ø!/°=ÀÑ3CÐ2EÑ!E‘ð!	Fñ$  Ø -Ð!1Ñ1Ðà Ð"3°^ÐDˆáÜÑ= GÔ=Ó=Ð=ä"Ø+Ð;LÐYgô
ð 	
r0   N)TFFT)r¤   r¥   r¦   r!   r§   r(   rª   r:   rV   rA   r¢   ri   r0   r.   rÊ   rÊ   ½  sZ   … ØÓØ—{‘{€Eˆ3�9‰9Ó"ò7ð #Ø"'Ø%*Ø ñ(
ð ð	(
ð
  ð(
ð #ð(
ð ô(
r0   rÊ   c                   ó   — e Zd ZU eed<   ej                  Zej                  ed<   dd„Z	 	 	 	 	 ddej                  dej                  de
ej                     d	e
ej                     d
edededeej                     fd„Zy)ÚFlaxBlenderbotDecoderLayerr3   r:   r%   Nc                 óP  — | j                   j                  | _        t        | j                   | j                  | j                   j                  | j                   j
                  d| j                  ¬«      | _        t        j                  | j                   j                  ¬«      | _        t        | j                   j                     | _        t        j                  | j                   j                  ¬«      | _        t        j"                  | j                  d¬«      | _        t        | j                   | j                  | j                   j                  | j                   j
                  | j                  ¬«      | _        t        j"                  | j                  d¬«      | _        t        j*                  | j                   j,                  | j                  t.        j                  j0                  j3                  | j                   j4                  «      ¬«      | _        t        j*                  | j                  | j                  t.        j                  j0                  j3                  | j                   j4                  «      ¬«      | _        t        j"                  | j                  d¬«      | _        y )NT)r3   r4   r5   r7   r8   r:   r?   r±   r²   r°   r´   )r3   rµ   r4   r2   Údecoder_attention_headsr·   r:   r¸   rE   rO   r7   rP   r   r»   r¼   r½   r¾   r¹   rº   Úencoder_attnÚencoder_attn_layer_normrF   Údecoder_ffn_dimrG   rH   rI   rJ   rÀ   rÁ   rÂ   rÃ   s    r.   rV   z FlaxBlenderbotDecoderLayer.setupø  s®  € ØŸ™×,Ñ,ˆŒÜ0Ø—;‘;Ø—n‘nØ—k‘k×9Ñ9Ø—K‘K×1Ñ1ØØ—*‘*ô
ˆŒô  ŸZ™Z¨T¯[©[×-@Ñ-@ÔAˆÔÜ# D§K¡K×$CÑ$CÑDˆÔÜ(*¯
©
¸¿¹×8VÑ8VÔ(WˆÔ%ä$&§L¡L°t·z±zÈ5Ô$QˆÔ!Ü3Ø—;‘;Ø—n‘nØ—k‘k×9Ñ9Ø—K‘K×1Ñ1Ø—*‘*ô
ˆÔô (*§|¡|¸$¿*¹*ÈeÔ'TˆÔ$Ü—8‘8Ø�K‰K×'Ñ'Ø—*‘*ÜŸ™×+Ñ+×2Ñ2°4·;±;×3GÑ3GÓHô
ˆŒô
 —8‘8Ø�N‰N $§*¡*¼#¿&¹&×:MÑ:M×:TÑ:TÐUY×U`ÑU`×UiÑUiÓ:jô
ˆŒô !#§¡°4·:±:ÀuÔ MˆÕr0   r]   rv   Úencoder_hidden_statesÚencoder_attention_maskr�   rÄ   r‚   c                 ó  — |}| j                  |«      }| j                  |||¬«      \  }}	| j                  ||¬«      }||z   }d }
|�B|}| j                  |«      }| j	                  |||¬«      \  }}
| j                  ||¬«      }||z   }|}| j                  |«      }| j                  | j                  |«      «      }| j                  ||¬«      }| j                  |«      }| j                  ||¬«      }||z   }|f}|r||	|
fz  }|S )N)r]   rv   r�   rÆ   )r]   r€   rv   )
rº   r¸   rP   rò   rñ   rÂ   r¼   rÀ   r¾   rÁ   )rT   r]   rv   rô   rõ   r�   rÄ   r‚   rÇ   Úself_attn_weightsÚcross_attn_weightsrÈ   s               r.   r¢   z#FlaxBlenderbotDecoderLayer.__call__  sZ  € ð !ˆØ×1Ñ1°-Ó@ˆð ,0¯>©>Ø'¸ÐS]ð ,:ó ,
Ñ(ˆÐ(ð ×*Ñ*¨=ÈÐ*ÓVˆØ  =Ñ0ˆð "ÐØ Ð,Ø$ˆHà ×8Ñ8¸ÓGˆMØ04×0AÑ0AØ+Ø!6Ø5ð 1Bó 1Ñ-ˆMÐ-ð
 !×.Ñ.¨}ÈMÐ.ÓZˆMØ$ }Ñ4ˆMð !ˆØ×-Ñ-¨mÓ<ˆØ×*Ñ*¨4¯8©8°MÓ+BÓCˆØ×5Ñ5°mÐS`Ð5ÓaˆØŸ™ Ó/ˆØ×*Ñ*¨=ÈÐ*ÓVˆØ  =Ñ0ˆà Ð"ˆáØÐ)Ð+=Ð>Ñ>ˆGàˆr0   r£   )NNFTT)r¤   r¥   r¦   r!   r§   r(   rª   r:   rV   r¬   r   rA   r   r¢   ri   r0   r.   rî   rî   ô  s¨   … ØÓØ—{‘{€Eˆ3�9‰9Ó"óNðJ 8<Ø8<Ø Ø"&Ø"ñ0à—{‘{ð0ð Ÿ™ð0ð  (¨¯©Ñ4ð	0ð
 !)¨¯©Ñ 5ð0ð ð0ð  ð0ð ð0ð 
ˆs�{‰{Ñ	ô0r0   rî   c                   ó¼   — e Zd ZU eed<   ej                  Zej                  ed<   d„ Z	 	 	 	 	 	 	 dde	ej                     de	ej                     deded	ed
edefd„Zy)Ú$FlaxBlenderbotDecoderLayerCollectionr3   r:   c           	      óú   — t        | j                  j                  «      D �cg c]-  }t        | j                  t	        |«      | j
                  ¬«      ‘Œ/ c}| _        | j                  j                  | _        y c c}w rÌ   )	rÎ   r3   Údecoder_layersrî   rÐ   r:   rÑ   Údecoder_layerdroprÓ   rÔ   s     r.   rV   z*FlaxBlenderbotDecoderLayerCollection.setupQ  rÖ   r×   Nrô   rõ   r‚   r�   rÄ   rØ   rÙ   c
           
      ój  — |rdnd }
|rdnd }|r|�dnd }| j                   D ]`  }|r|
|fz  }
t        j                  dd«      }|s|| j                  k  rd}n ||||||||¬«      }|d   }|sŒL||d   fz  }|€ŒX||d   fz  }Œb |r|
|fz  }
||
||g}|	st	        d„ |D «       «      S t        ||
||¬«      S )	Nri   r   r    ©NNN)rv   rô   rõ   r�   rÄ   r‚   rY   c              3   ó&   K  — | ]	  }|€Œ|–— Œ y ­wrÜ   ri   rÝ   s     r.   rà   z@FlaxBlenderbotDecoderLayerCollection.__call__.<locals>.<genexpr>‰  rá   râ   ©rä   r]   rå   Úcross_attentions)rÑ   ræ   rç   rÓ   rs   r   )rT   r]   rv   rô   rõ   r‚   r�   rÄ   rØ   rÙ   ré   Úall_self_attnsÚall_cross_attentionsÚdecoder_layerrë   rì   rÈ   s                    r.   r¢   z-FlaxBlenderbotDecoderLayerCollection.__call__X  s  € ñ #7™B¸DÐÙ0™°dˆÙ&7Ð<QÐ<]™rÐdhÐà!Ÿ[™[ò 	@ˆMÙ#Ø! mÐ%5Ñ5Ð!ä"(§.¡.°°AÓ"6ÐÙ Ð&9¸D¿N¹NÒ&JØ 2‘á -Ø!Ø#1Ø*?Ø+AØ)Ø&7Ø"/ô!�ð *¨!Ñ,ˆMÚ Ø =°Ñ#3Ð"5Ñ5�à(Ñ4Ø(¨]¸1Ñ-=Ð,?Ñ?Ñ(ð/	@ñ4  Ø -Ð!1Ñ1Ðà Ð"3°^ÐEYÐZˆáÜÑ= GÔ=Ó=Ð=ä<Ø+Ø+Ø%Ø1ô	
ð 	
r0   )NNTFFFT)r¤   r¥   r¦   r!   r§   r(   rª   r:   rV   r   r¬   rA   r¢   ri   r0   r.   rú   rú   M  s“   … ØÓØ—{‘{€Eˆ3�9‰9Ó"ò7ð 8<Ø8<Ø"Ø Ø"'Ø%*Ø ñ8
ð  (¨¯©Ñ4ð	8
ð
 !)¨¯©Ñ 5ð8
ð ð8
ð ð8
ð  ð8
ð #ð8
ð ô8
r0   rú   c            	       ó”   — e Zd ZU eed<   ej                  ed<   ej                  Z	ej                  ed<   d„ Z
	 	 	 	 ddedededefd	„Zy
)ÚFlaxBlenderbotEncoderr3   Úembed_tokensr:   c                 óÌ  — t        j                  | j                  j                  ¬«      | _        | j                  j
                  }| j                  j                  | _        | j                  j                  | _	        | j                  j                  rt        j                  |«      nd| _        t        j                  | j                  j                  |t        j                   j                   j#                  | j                  j$                  «      ¬«      | _        t)        | j                  | j*                  «      | _        t        j.                  | j*                  d¬«      | _        y ©Nr?   g      ð?)Úembedding_initr±   r²   )rE   rO   r3   r7   rP   rµ   r#   Úpadding_idxrR   Úmax_source_positionsÚscale_embeddingÚmathÚsqrtÚembed_scaleÚEmbedrG   rH   rI   rJ   Úembed_positionsrÊ   r:   rÑ   r¹   Ú
layer_norm©rT   r4   s     r.   rV   zFlaxBlenderbotEncoder.setup˜  sá   € ÜŸZ™Z¨T¯[©[×-@Ñ-@ÔAˆÔà—K‘K×'Ñ'ˆ	ØŸ;™;×3Ñ3ˆÔØ$(§K¡K×$GÑ$GˆÔ!Ø37·;±;×3NÒ3Nœ4Ÿ9™9 YÔ/ÐTWˆÔä!Ÿx™xØ�K‰K×/Ñ/ØÜŸ6™6×.Ñ.×5Ñ5°d·k±k×6JÑ6JÓKô 
ˆÔô
 ;¸4¿;¹;ÈÏ
É
ÓSˆŒÜŸ,™,¨T¯Z©ZÀÔGˆ�r0   rÄ   rØ   rÙ   r‚   c                 óÊ  — |j                   }|j                  d|d   «      }| j                  |«      | j                  z  }	| j	                  |«      }
|	|
z   }| j                  ||¬«      }| j                  ||||||¬«      }|d   }| j                  |«      }d }|r|d   }|d d |fz   }|s#||f|r|dd  n|dd  z   }t        d„ |D «       «      S t        |||j                  ¬«      S )	Nr'   rÆ   )r‚   rÄ   rØ   rÙ   r   r    rY   c              3   ó&   K  — | ]	  }|€Œ|–— Œ y ­wrÜ   ri   rÝ   s     r.   rà   z1FlaxBlenderbotEncoder.__call__.<locals>.<genexpr>Ï  rá   râ   rã   )r[   rZ   r  r  r  rP   rÑ   r  rs   r   rå   )rT   r"   rv   Úposition_idsrÄ   rØ   rÙ   r‚   Úinput_shapeÚinputs_embedsÚ	embed_posr]   rÈ   Úlast_hidden_statess                 r.   r¢   zFlaxBlenderbotEncoder.__call__¨  s*  € ð  —o‘oˆØ×%Ñ% b¨+°b©/Ó:ˆ	à×)Ñ)¨)Ó4°t×7GÑ7GÑGˆà×(Ñ(¨Ó6ˆ	à%¨	Ñ1ˆØ×*Ñ*¨=ÈÐ*ÓVˆà—+‘+ØØØ'Ø/Ø!5Ø#ð ó 
ˆð % Q™ZÐØ!Ÿ_™_Ð-?Ó@Ðð ˆÙØ# A™JˆMØ)¨#¨2Ð.Ð2DÐ1FÑFˆMáØ)¨=Ð9ÑL`¸WÀQÀR¹[ÐfmÐnoÐnpÐfqÑrˆGÜÑ= GÔ=Ó=Ð=ä"Ø0Ø'Ø×)Ñ)ô
ð 	
r0   N©FFTT)r¤   r¥   r¦   r!   r§   rE   r  r(   rª   r:   rV   rA   r¢   ri   r0   r.   r  r  “  se   … ØÓØ—(‘(ÓØ—{‘{€Eˆ3�9‰9Ó"òHð* #(Ø%*Ø Ø"ñ-
ð
  ð-
ð #ð-
ð ð-
ð ô-
r0   r  c                   óÚ   — e Zd ZU eed<   ej                  ed<   ej                  Z	ej                  ed<   d„ Z
	 	 	 	 	 	 	 ddeej                     deej                     ded	ed
ededefd„Zy)ÚFlaxBlenderbotDecoderr3   r  r:   c                 óô  — t        j                  | j                  j                  ¬«      | _        | j                  j
                  }| j                  j                  | _        | j                  j                  | _	        | j                  j                  r)t        j                  | j                  j
                  «      nd| _        t        j                  | j                  j                  |t        j                   j                   j#                  | j                  j$                  «      ¬«      | _        t)        | j                  | j*                  «      | _        t        j.                  | j*                  d¬«      | _        y r
  )rE   rO   r3   r7   rP   rµ   r#   r  rR   Úmax_target_positionsr  r  r  r  r  rG   rH   rI   rJ   r  rú   r:   rÑ   r¹   r  r  s     r.   rV   zFlaxBlenderbotDecoder.setupÝ  së   € ÜŸZ™Z¨T¯[©[×-@Ñ-@ÔAˆÔà—K‘K×'Ñ'ˆ	ØŸ;™;×3Ñ3ˆÔØ$(§K¡K×$GÑ$GˆÔ!Ø=A¿[¹[×=XÒ=Xœ4Ÿ9™9 T§[¡[×%8Ñ%8Ô9Ð^aˆÔä!Ÿx™xØ�K‰K×/Ñ/ØÜŸ6™6×.Ñ.×5Ñ5°d·k±k×6JÑ6JÓKô 
ˆÔô ;¸4¿;¹;ÈÏ
É
ÓSˆŒÜŸ,™,¨T¯Z©ZÀÔGˆ�r0   Nrô   rõ   r�   rÄ   rØ   rÙ   r‚   c                 óæ  — |j                   }|j                  d|d   «      }| j                  |«      | j                  z  }| j	                  |«      }||z   }| j                  ||
¬«      }| j                  |||||
||||	¬«	      }|d   }| j                  |«      }d }|r|d   }|d d |fz   }|	s#||f|r|dd  n|dd  z   }t        d„ |D «       «      S t        |||j                  |j                  ¬«      S )	Nr'   rÆ   )r‚   r�   rÄ   rØ   rÙ   r   r    rY   c              3   ó&   K  — | ]	  }|€Œ|–— Œ y ­wrÜ   ri   rÝ   s     r.   rà   z1FlaxBlenderbotDecoder.__call__.<locals>.<genexpr>  rá   râ   r  )r[   rZ   r  r  r  rP   rÑ   r  rs   r   rå   r  )rT   r"   rv   r  rô   rõ   r�   rÄ   rØ   rÙ   r‚   r  r  Ú	positionsr]   rÈ   r  s                    r.   r¢   zFlaxBlenderbotDecoder.__call__î  s>  € ð  —o‘oˆØ×%Ñ% b¨+°b©/Ó:ˆ	à×)Ñ)¨)Ó4°t×7GÑ7GÑGˆð ×(Ñ(¨Ó6ˆ	à%¨	Ñ1ˆØ×*Ñ*¨=ÈÐ*ÓVˆà—+‘+ØØØ!Ø"Ø'Ø!Ø/Ø!5Ø#ð ó 

ˆð % Q™ZÐØ!Ÿ_™_Ð-?Ó@Ðð ˆÙØ# A™JˆMØ)¨#¨2Ð.Ð2DÐ1FÑFˆMáØ)¨=Ð9ÑL`¸WÀQÀR¹[ÐfmÐnoÐnpÐfqÑrˆGÜÑ= GÔ=Ó=Ð=ä<Ø0Ø'Ø×)Ñ)Ø$×5Ñ5ô	
ð 	
r0   )NNFFFTT)r¤   r¥   r¦   r!   r§   rE   r  r(   rª   r:   rV   r   r¬   rA   r¢   ri   r0   r.   r  r  Ø  sž   … ØÓØ—(‘(ÓØ—{‘{€Eˆ3�9‰9Ó"òHð, 8<Ø8<Ø Ø"'Ø%*Ø Ø"ñ6
ð
  (¨¯©Ñ4ð6
ð !)¨¯©Ñ 5ð6
ð ð6
ð  ð6
ð #ð6
ð ð6
ð ô6
r0   r  c            	       ó‚   — e Zd ZU eed<   ej                  Zej                  ed<   d„ Zd„ Z	d„ Z
	 	 	 	 ddededed	efd
„Zy)ÚFlaxBlenderbotModuler3   r:   c                 óÞ  — t        j                  | j                  j                  | j                  j                  t
        j                   j                  j                  | j                  j                  «      | j                  ¬«      | _
        t        | j                  | j                  | j                  ¬«      | _        t        | j                  | j                  | j                  ¬«      | _        y )N)r  r:   )r:   r  )rE   r  r3   Ú
vocab_sizerµ   rG   rH   rI   rJ   r:   Úsharedr  Úencoderr  ÚdecoderrÃ   s    r.   rV   zFlaxBlenderbotModule.setup,  s•   € Ü—h‘hØ�K‰K×"Ñ"Ø�K‰K×ÑÜŸ6™6×.Ñ.×5Ñ5°d·k±k×6JÑ6JÓKØ—*‘*ô	
ˆŒô -¨T¯[©[ÀÇ
Á
ÐY]×YdÑYdÔeˆŒÜ,¨T¯[©[ÀÇ
Á
ÐY]×YdÑYdÔeˆ�r0   c                 ó   — | j                   S rÜ   )r*  rÃ   s    r.   Ú_get_encoder_modulez(FlaxBlenderbotModule._get_encoder_module7  ó   € Ø�|‰|Ðr0   c                 ó   — | j                   S rÜ   )r+  rÃ   s    r.   Ú_get_decoder_modulez(FlaxBlenderbotModule._get_decoder_module:  r.  r0   rÄ   rØ   rÙ   r‚   c                 ó*  — | j                  ||||||	|
¬«      }| j                  ||||d   ||||	|
¬«	      }|	s||z   S t        |j                  |j                  |j
                  |j                  |j                  |j                  |j
                  ¬«      S )N)r"   rv   r  rÄ   rØ   rÙ   r‚   r   )	r"   rv   r  rô   rõ   rÄ   rØ   rÙ   r‚   )rä   Údecoder_hidden_statesÚdecoder_attentionsr  Úencoder_last_hidden_staterô   Úencoder_attentions)r*  r+  r   rä   r]   rå   r  )rT   r"   rv   Údecoder_input_idsÚdecoder_attention_maskr  Údecoder_position_idsrÄ   rØ   rÙ   r‚   Úencoder_outputsÚdecoder_outputss                r.   r¢   zFlaxBlenderbotModule.__call__=  s½   € ð Ÿ,™,ØØ)Ø%Ø/Ø!5Ø#Ø'ð 'ó 
ˆð Ÿ,™,Ø'Ø1Ø-Ø"1°!Ñ"4Ø#1Ø/Ø!5Ø#Ø'ð 'ó 

ˆñ Ø" _Ñ4Ð4ä%Ø-×?Ñ?Ø"1×"?Ñ"?Ø.×9Ñ9Ø,×=Ñ=Ø&5×&GÑ&GØ"1×"?Ñ"?Ø.×9Ñ9ô
ð 	
r0   Nr  )r¤   r¥   r¦   r!   r§   r(   rª   r:   rV   r-  r0  rA   r¢   ri   r0   r.   r&  r&  (  se   … ØÓØ—{‘{€Eˆ3�9‰9Ó"ò	fòòð #(Ø%*Ø Ø"ñ.
ð  ð.
ð #ð.
ð ð.
ð ô.
r0   r&  c                   ó–  ‡ — e Zd ZU eZdZeed<   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$dej&                  j(                  d	ededefd„Zd„ Z ee«       eee¬«      	 	 	 	 	 	 	 	 d%dej8                  deej8                     deej8                     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j8                     deej8                     deej8                     d edee   dee   dee   dededefd!„«       «       Z" e#e$«      	 	 	 	 	 	 	 	 	 	 	 d'dej8                  deej8                     d"eej8                     deej8                     deej8                     deej8                     dee   dee   dee   dededefd#„«       Z%ˆ xZ&S )(ÚFlaxBlenderbotPreTrainedModelÚmodelÚbase_model_prefixNÚmodule_class)r    r    r   Tr3   r  Úseedr:   Ú_do_initc                 óZ   •—  | j                   d||dœ|¤Ž}t        ‰| �	  ||||||¬«       y )N©r3   r:   )r  r@  r:   rA  ri   )r?  ÚsuperÚ__init__)	rT   r3   r  r@  r:   rA  ÚkwargsÚmoduleÚ	__class__s	           €r.   rE  z&FlaxBlenderbotPreTrainedModel.__init__s  s=   ø€ ð #�×"Ñ"ÐH¨&¸ÑHÀÑHˆÜ‰Ñ˜ °[ÀtÐSXÐckÐÕlr0   ÚrngÚparamsr%   c           	      ó8  — t        j                  |d¬«      }|j                  d   j                  | j                  j
                  «      }t        j                  |«      }|}t        j                  |«      }|j                  \  }}	t        j                  t        j                  |	«      d d d …f   ||	f«      }
t        j                  t        j                  |	«      d d d …f   ||	f«      }t        j                  j                  |«      \  }}||dœ}| j                  j                  ||||||
|«      d   }|�dt        t!        |«      «      }t        t!        |«      «      }| j"                  D ]
  }||   ||<   Œ t        «       | _        t%        t'        |«      «      S |S )NÚi4rB   ).r'   )rJ  r7   rJ  )r(   rm   r*   r+   r3   Úeos_token_idÚ	ones_liker[   rq   rr   rG   ræ   ÚsplitrG  Úinitr   r	   Ú_missing_keysr   r   )rT   rI  r  rJ  r"   rv   r6  r7  r—   Úsequence_lengthr  r8  Ú
params_rngrˆ   ÚrngsÚrandom_paramsÚmissing_keys                    r.   Úinit_weightsz*FlaxBlenderbotPreTrainedModel.init_weights  s  € ä—I‘I˜k°Ô6ˆ	à—L‘L Ñ+×/Ñ/°·±×0HÑ0HÓIˆ	ÜŸ™ yÓ1ˆØ%ÐÜ!$§¡¨yÓ!9Ðà&/§o¡oÑ#ˆ
�OÜ×'Ñ'¬¯
©
°?Ó(CÀDÊ!ÀGÑ(LÈzÐ[jÐNkÓlˆÜ"×/Ñ/´·
±
¸?Ó0KÈDÒRSÈGÑ0TÐWaÐcrÐVsÓtÐä"%§*¡*×"2Ñ"2°3Ó"7Ñˆ
�KØ$°Ñ=ˆàŸ™×(Ñ(ØØØØØ"ØØ ó
ð ñˆð ÐÜ(¬°-Ó)@ÓAˆMÜ!¤(¨6Ó"2Ó3ˆFØ#×1Ñ1ò A�Ø&3°KÑ&@��{Ò#ðAä!$£ˆDÔÜœ.¨Ó0Ó1Ð1à Ð r0   c           	      óª  — t        j                  ||fd¬«      }t        j                  |«      }t        j                  t        j                  t        j
                  |«      j                  d   «      |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.
        rL  rB   r'   c                 ó8   — | j                  «       } ||||fi |¤ŽS rÜ   ©r0  ©rG  r6  r7  r8  rF  Údecoder_modules         r.   Ú_decoder_forwardzBFlaxBlenderbotPreTrainedModel.init_cache.<locals>._decoder_forward¸  ó0   € Ø#×7Ñ7Ó9ˆNÙ!Ø!Ø&Ø$ñð ñ	ð r0   r   T)r6  r7  r8  rô   r�   Úmethodrb   )r(   rQ   rN  rq   rr   Ú
atleast_2dr[   rG  rP  rG   ræ   r   r	   )	rT   r—   ry   r9  r6  r7  r8  r]  Úinit_variabless	            r.   r�   z(FlaxBlenderbotPreTrainedModel.init_cache£  sÀ   € ô  ŸH™H j°*Ð%=ÀTÔJÐÜ!$§¡Ð/@Ó!AÐÜ"×/Ñ/Ü�J‰J”s—~‘~Ð&7Ó8×>Ñ>¸rÑBÓCÐEV×E\ÑE\ó 
Ðò	ð Ÿ™×)Ñ)Ü�J‰J×Ñ˜qÓ!Ø/Ø#9Ø!5Ø"1°!Ñ"4ØØ#ð *ó 
ˆô ˜ wÑ/Ó0Ð0r0   ©Úoutput_typeÚconfig_classr"   rv   r  rÄ   rØ   rÙ   Útrainrˆ   c
                 óT  — |�|n| j                   j                  }|�|n| j                   j                  }|�|n| j                   j                  }|€t	        j
                  |«      }|€A|j                  \  }
}t	        j                  t	        j                  |«      ddd…f   |
|f«      }i }|	�|	|d<   d„ }| j                  j                  d|xs | j                  it	        j                  |d¬«      t	        j                  |d¬«      t	        j                  |d¬«      |||| ||¬«
      S )a/  
        Returns:

        Example:

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

        >>> model = FlaxBlenderbotForConditionalGeneration.from_pretrained("facebook/blenderbot-400M-distill")
        >>> tokenizer = AutoTokenizer.from_pretrained("facebook/blenderbot-400M-distill")

        >>> text = "My friends are cool but they eat too many carbs."
        >>> inputs = tokenizer(text, max_length=1024, return_tensors="jax")
        >>> encoder_outputs = model.encode(**inputs)
        ```Nr7   c                 ó8   — | j                  «       } ||||fi |¤ŽS rÜ   )r-  )rG  r"   rv   r  rF  Úencode_modules         r.   Ú_encoder_forwardz>FlaxBlenderbotPreTrainedModel.encode.<locals>._encoder_forwardú  s$   € Ø"×6Ñ6Ó8ˆMÙ  ¨N¸LÑSÈFÑSÐSr0   rJ  rL  rB   )	r"   rv   r  rÄ   rØ   rÙ   r‚   rT  r_  )r3   rÄ   rØ   rÙ   r(   rN  r[   rq   rr   rG  ÚapplyrJ  rg   )rT   r"   rv   r  rÄ   rØ   rÙ   re  rJ  rˆ   r—   rR  rT  ri  s                 r.   Úencodez$FlaxBlenderbotPreTrainedModel.encodeÌ  s.  € ð: 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×BYÑBYˆàÐ!Ü Ÿ]™]¨9Ó5ˆNØÐØ*3¯/©/Ñ'ˆJ˜Ü×+Ñ+¬C¯J©J°Ó,GÈÊaÈÑ,PÐS]Ð_nÐRoÓpˆLð ˆØÐ"Ø)ˆD�‰Oò	Tð �{‰{× Ñ Ø�vÒ, §¡Ð-Ü—i‘i 	°Ô6ÜŸ9™9 ^¸4Ô@ÜŸ™ <°tÔ<Ø/Ø!5Ø#Ø#˜)ØØ#ð !ó 
ð 	
r0   rõ   r7  r8  Úpast_key_valuesc                 ó¤  — |�|n| j                   j                  }|�|n| j                   j                  }|	�|	n| j                   j                  }	|d   }|€)|j                  dd \  }}t        j                  ||f«      }|j                  \  }}|€t        j                  ||f«      }|€?|�t        d«      ‚t        j                  t        j                  |«      ddd…f   ||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
¬«      |t        j                  |d
¬«      |||	|
 |||¬«      }|�|	r|\  }}t        |d   «      |d<   |S |�"|	s |\  }}|dd t        |d   «      fz   |dd z   }|S )a–  
        Returns:

        Example:

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

        >>> model = FlaxBlenderbotForConditionalGeneration.from_pretrained("facebook/blenderbot-400M-distill")
        >>> tokenizer = AutoTokenizer.from_pretrained("facebook/blenderbot-400M-distill")

        >>> text = "My friends are cool but they eat too many carbs."
        >>> inputs = tokenizer(text, max_length=1024, return_tensors="jax")
        >>> 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)
        >>> last_decoder_hidden_states = outputs.last_hidden_state
        ```Nr   rY   úKMake sure to provide `decoder_position_ids` when passing `past_key_values`.r7   rJ  rb   Fc                 ó8   — | j                  «       } ||||fi |¤ŽS rÜ   rZ  r[  s         r.   r]  z>FlaxBlenderbotPreTrainedModel.decode.<locals>._decoder_forward[  r^  r0   rL  rB   ©r6  r7  r8  rô   rõ   rÄ   rØ   rÙ   r‚   rT  Úmutabler_  rl  r    )r3   rÄ   rØ   rÙ   r[   r(   rQ   rD   rq   rr   rJ  rG  rj  rg   r	   )rT   r6  r9  rõ   r7  r8  rl  rÄ   rØ   rÙ   re  rJ  rˆ   rô   r—   rR  rT  Úinputsrq  r]  rÈ   Úpasts                         r.   Údecodez$FlaxBlenderbotPreTrainedModel.decode  s#  € ðR 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Ð"àÐ'ØÐ*Ü Ð!nÓoÐoä#&×#3Ñ#3Ü—
‘
˜?Ó+¨D²!¨GÑ4°zÀ?Ð6Só$Ð ð
 ˆØÐ"Ø)ˆD�‰Oà˜FÒ1 d§k¡kÐ2ˆñ
 Ø-ˆF�7‰OØ�i‰GàˆGò	ð —+‘+×#Ñ#ØÜ!Ÿi™iÐ(9ÀÔFÜ#&§9¡9Ð-CÈ4Ô#PÜ!$§¡Ð+?ÀtÔ!LØ"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àˆr0   r6  c                 óò  — |�|n| j                   j                  }|�|n| j                   j                  }|	�|	n| j                   j                  }	|€t	        j
                  |«      }|€A|j                  \  }}t	        j                  t	        j                  |«      d d d …f   ||f«      }|€6t        || j                   j                  | j                   j                  ¬«      }|€t	        j
                  |«      }|€A|j                  \  }}t	        j                  t	        j                  |«      d d d …f   ||f«      }|�d|ini }| j                  j                  d|xs | j                  it	        j                  |d¬«      t	        j                  |d¬«      t	        j                  |d¬«      t	        j                  |d¬«      t	        j                  |d¬«      t	        j                  |d¬«      |||	|
 |¬«      S )N)r$   r7   rJ  rL  rB   )r"   rv   r  r6  r7  r8  rÄ   rØ   rÙ   r‚   rT  )r3   rÄ   rØ   rÙ   r(   rN  r[   rq   rr   r/   r#   r$   rG  rj  rJ  rg   )rT   r"   rv   r6  r7  r  r8  rÄ   rØ   rÙ   re  rJ  rˆ   r—   rR  rT  s                   r.   r¢   z&FlaxBlenderbotPreTrainedModel.__call__  sØ  € ð  2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×BYÑBYˆð Ð!Ü Ÿ]™]¨9Ó5ˆNØÐØ*3¯/©/Ñ'ˆJ˜Ü×+Ñ+¬C¯J©J°Ó,GÈÊaÈÑ,PÐS]Ð_nÐRoÓpˆLð Ð$Ü 2Ø˜4Ÿ;™;×3Ñ3ÈDÏKÉK×LnÑLnô!Ðð "Ð)Ü%(§]¡]Ð3DÓ%EÐ"ØÐ'Ø*;×*AÑ*AÑ'ˆJ˜Ü#&×#3Ñ#3Ü—
‘
˜?Ó+¨D²!¨GÑ4°zÀ?Ð6Só$Ð ð
 ,7Ð+B�	˜;Ñ'Èˆà�{‰{× Ñ Ø�vÒ, §¡Ð-Ü—i‘i 	°Ô6ÜŸ9™9 ^¸4Ô@ÜŸ™ <°tÔ<Ü!Ÿi™iÐ(9ÀÔFÜ#&§9¡9Ð-CÈ4Ô#PÜ!$§¡Ð+?ÀtÔ!LØ/Ø!5Ø#Ø#˜)Øð !ó 
ð 	
r0   rÜ   )NNNNNFNN©
NNNNNNNFNN)NNNNNNNNFNN)'r¤   r¥   r¦   r!   rd  r>  rÐ   r§   r?  rE   ÚModuler(   rª   r   r¨   r:   rA   rE  rG   ræ   r   r   rW  r�   r   Ú"BLENDERBOT_ENCODE_INPUTS_DOCSTRINGr   r   r¬   r   Údictrk  Ú"BLENDERBOT_DECODE_INPUTS_DOCSTRINGr   rt  r   ÚBLENDERBOT_INPUTS_DOCSTRINGr¢   Ú__classcell__)rH  s   @r.   r<  r<  n  sA  ø… Ø#€LØ$Ð�sÓ$Ø"€L�"—)‘)Ó"ð
 #)ØØŸ;™;Øñ
mà ð
mð ˜3‘Zð
mð ð	
mð
 �y‰yð
mð õ
mñ"! §
¡
× 2Ñ 2ð "!Àð "!ÐPZð "!Ðfpó "!òH'1ñR Ð<Ó=ÙÐ+>ÐM]Ô^ð 15Ø.2Ø,0Ø/3Ø&*ØØØ#ñ;
à—;‘;ð;
ð ! §¡Ñ-ð;
ð ˜sŸ{™{Ñ+ð	;
ð
 $ D™>ð;
ð ' t™nð;
ð ˜d‘^ð;
ð ð;
ð ð;
ð ò;
ó _ó >ð;
ñz Ð<Ó=ÙØAÐP`ôð 9=Ø8<Ø6:Ø $Ø,0Ø/3Ø&*ØØØ#ñnð !)¨¯©Ñ 5ð	nð
 !)¨¯©Ñ 5ðnð ' s§{¡{Ñ3ðnð ðnð $ D™>ðnð ' t™nðnð ˜d‘^ðnð ðnð ðnð ònóó >ðnñ` +Ð+FÓGð 15Ø37Ø8<Ø.2Ø6:Ø,0Ø/3Ø&*ØØØ#ñ9
à—;‘;ð9
ð ! §¡Ñ-ð9
ð $ C§K¡KÑ0ð	9
ð
 !)¨¯©Ñ 5ð9
ð ˜sŸ{™{Ñ+ð9
ð ' s§{¡{Ñ3ð9
ð $ D™>ð9
ð ' t™nð9
ð ˜d‘^ð9
ð ð9
ð ð9
ð ò9
ó Hô9
r0   r<  z_The bare MBart Model transformer outputting raw hidden-states without any specific head on top.c                   óR   — e Zd ZU eed<   ej                  Zej                  ed<   eZ	y)ÚFlaxBlenderbotModelr3   r:   N)
r¤   r¥   r¦   r!   r§   r(   rª   r:   r&  r?  ri   r0   r.   r~  r~  ¼  s!   … ð
 ÓØ—{‘{€Eˆ3�9‰9Ó"Ø'�Lr0   r~  c            	       óê   — e Zd ZU eed<   ej                  Zej                  ed<   ej                  j                  j                  Zedej                  f   ed<   d„ Zd„ Zd„ Z	 	 	 	 dded	ed
edefd„Zy)Ú,FlaxBlenderbotForConditionalGenerationModuler3   r:   .Ú	bias_initc                 óÖ  — t        | j                  | j                  ¬«      | _        t	        j
                  | j                  j                  j                  d| j                  t        j                  j                  j                  | j                  j                  «      ¬«      | _        | j                  d| j                  d| j                  j                  j                  f«      | _        y )NrC  Fr<   Úfinal_logits_biasr    )r&  r3   r:   r=  rE   rF   r)  Únum_embeddingsrG   rH   rI   rJ   Úlm_headÚparamr�  rƒ  rÃ   s    r.   rV   z2FlaxBlenderbotForConditionalGenerationModule.setupÏ  sœ   € Ü)°·±ÀDÇJÁJÔOˆŒ
Ü—x‘xØ�J‰J×Ñ×,Ñ,ØØ—*‘*ÜŸ™×+Ñ+×2Ñ2°4·;±;×3GÑ3GÓHô	
ˆŒð "&§¡Ð,?ÀÇÁÐRSÐUY×U_ÑU_×UfÑUf×UuÑUuÐQvÓ!wˆÕr0   c                 ó.   — | j                   j                  S rÜ   )r=  r*  rÃ   s    r.   r-  z@FlaxBlenderbotForConditionalGenerationModule._get_encoder_moduleÙ  ó   € Ø�z‰z×!Ñ!Ð!r0   c                 ó.   — | j                   j                  S rÜ   )r=  r+  rÃ   s    r.   r0  z@FlaxBlenderbotForConditionalGenerationModule._get_decoder_moduleÜ  rˆ  r0   rÄ   rØ   rÙ   r‚   c                 ód  — | j                  |||||||||	|
¬«
      }|d   }| j                  j                  rJ| j                   j                  d   d   d   }| j                  j                  dd|j                  ii|«      }n| j	                  |«      }|t        j                  j                  | j                  j                  | j                  «      «      z  }|	s|f|dd  z   }|S t        ||j                  |j                  |j                   |j"                  |j$                  |j&                  ¬«      S )	N)
r"   rv   r6  r7  r  r8  rÄ   rØ   rÙ   r‚   r   rJ  r)  Ú	embeddingÚkernelr    )Úlogitsr2  r3  r  r4  rô   r5  )r=  r3   Útie_word_embeddingsrŒ   r…  rj  ÚTrG   r   Ústop_gradientrƒ  r‘   r:   r   r2  r3  r  r4  rô   r5  )rT   r"   rv   r6  r7  r  r8  rÄ   rØ   rÙ   r‚   rÈ   r]   Úshared_embeddingÚ	lm_logitsÚoutputs                   r.   r¢   z5FlaxBlenderbotForConditionalGenerationModule.__call__ß  s0  € ð —*‘*ØØ)Ø/Ø#9Ø%Ø!5Ø/Ø!5Ø#Ø'ð ó 
ˆð   ™
ˆà�;‰;×*Ò*Ø#Ÿz™z×3Ñ3°HÑ=¸hÑGÈÑTÐØŸ™×*Ñ*¨H°xÐAQ×ASÑASÐ6TÐ+UÐWdÓe‰IàŸ™ ]Ó3ˆIà”S—W‘W×*Ñ*¨4×+AÑ+A×+HÑ+HÈÏÉÓ+TÓUÑUˆ	áØ�\ G¨A¨B KÑ/ˆFØˆMä"ØØ")×"?Ñ"?Ø&×9Ñ9Ø$×5Ñ5Ø&-×&GÑ&GØ")×"?Ñ"?Ø&×9Ñ9ô
ð 	
r0   Nr  )r¤   r¥   r¦   r!   r§   r(   rª   r:   rG   rE   rH   rm   r�  r   r¬   rV   r-  r0  rA   r¢   ri   r0   r.   r€  r€  Ê  s�   … ØÓØ—{‘{€Eˆ3�9‰9Ó"Ø,/¯F©F×,?Ñ,?×,EÑ,E€Iˆx˜˜SŸ[™[Ð(Ñ)ÓEòxò"ò"ð #(Ø%*Ø Ø"ñ0
ð  ð0
ð #ð0
ð ð0
ð ô0
r0   r€  zRThe Blenderbot Model with a language modeling head. Can be used for summarization.c                   óp  — e Zd ZU eZej                  Zej                  ed<    e	e
«       eee¬«      	 	 	 	 	 	 	 	 	 	 ddeej                     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)Ú&FlaxBlenderbotForConditionalGenerationr:   rb  Nrõ   r7  r8  rl  rÄ   rØ   rÙ   re  rJ  rˆ   c                 ó(  ‡ — |�|n‰ j                   j                  }|�|n‰ j                   j                  }|	�|	n‰ j                   j                  }	|d   }|€)|j                  dd \  }}t        j                  ||f«      }|j                  \  }}|€t        j                  ||f«      }|€?|�t        d«      ‚t        j                  t        j                  |«      ddd…f   ||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
¬«      |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 )aw  
        Returns:

        Example:

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

        >>> model = FlaxBlenderbotForConditionalGeneration.from_pretrained("facebook/blenderbot-400M-distill")
        >>> tokenizer = AutoTokenizer.from_pretrained("facebook/blenderbot-400M-distill")

        >>> text = "My friends are cool but they eat too many carbs."
        >>> inputs = tokenizer(text, max_length=1024, return_tensors="jax")
        >>> 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   rY   rn  r7   rJ  rb   Fc                 óL  •— | j                  «       } ||||fi |¤Ž}|d   }‰
j                  j                  rJ| j                  j                  d   d   d   }| j
                  j                  dd|j                  ii|«      }	n| j                  |«      }	|	| j                  z  }	|	|fS )Nr   rJ  r)  r‹  rŒ  )	r0  r3   rŽ  r=  rŒ   r…  rj  r�  rƒ  )rG  r6  r7  r8  rF  r\  rÈ   r]   r‘  r’  rT   s             €r.   r]  zGFlaxBlenderbotForConditionalGeneration.decode.<locals>._decoder_forwardg  s¶   ø€ Ø#×7Ñ7Ó9ˆNÙ$Ø!Ø&Ø$ñð ñ	ˆGð $ A™JˆMà�{‰{×.Ò.Ø#)§<¡<×#9Ñ#9¸(Ñ#CÀHÑ#MÈkÑ#ZÐ Ø"ŸN™N×0Ñ0°(¸XÐGW×GYÑGYÐ<ZÐ1[Ð]jÓk‘	à"ŸN™N¨=Ó9�	à˜×1Ñ1Ñ1ˆIØ˜gÐ%Ð%r0   rL  rB   rp  )r�  r]   rå   r  r    rl  )r3   rÄ   rØ   rÙ   r[   r(   rQ   rD   rq   rr   rJ  rG  rj  rg   r   r]   rå   r  r	   )rT   r6  r9  rõ   r7  r8  rl  rÄ   rØ   rÙ   re  rJ  rˆ   rô   r—   rR  rT  rr  rq  r]  rÈ   r’  r:  rs  s   `                       r.   rt  z-FlaxBlenderbotForConditionalGeneration.decode  ss  ø€ ðN 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Ð"àÐ'ØÐ*Ü Ð!nÓoÐoä#&×#3Ñ#3Ü—
‘
˜?Ó+¨D²!¨GÑ4°zÀ?Ð6Só$Ð ð
 ˆØÐ"Ø)ˆD�‰Oà˜FÒ1 d§k¡kÐ2ˆñ
 Ø-ˆF�7‰OØ�i‰GàˆGô	&ð& —+‘+×#Ñ#ØÜ!Ÿi™iÐ(9ÀÔFÜ#&§9¡9Ð-CÈ4Ô#PÜ!$§¡Ð+?ÀtÔ!LØ"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àˆr0   rv   c                 óN  — |j                   \  }}| j                  |||«      }	t        j                  ||fd¬«      }
|�-|j	                  d¬«      dz
  }t        j                  |
|d«      }
n4t        j                  t        j                  |d¬«      d d d …f   ||f«      }|	|||
|dœS )NrL  rB   r'   r†   r    )r   r   )rl  r9  rõ   r7  r8  )	r[   r�   r(   rQ   Úcumsumr   rp   rq   rr   )rT   r6  ry   rv   r7  r9  rF  r—   Ú
seq_lengthrl  Úextended_attention_maskr  s               r.   Úprepare_inputs_for_generationzDFlaxBlenderbotForConditionalGeneration.prepare_inputs_for_generation¢  s½   € ð "3×!8Ñ!8Ñˆ
�JàŸ/™/¨*°jÀ/ÓRˆô #&§(¡(¨J¸
Ð+CÈ4Ô"PÐØ!Ð-Ø1×8Ñ8¸bÐ8ÓAÀAÑEˆLÜ&)×&>Ñ&>Ð?VÐXnÐpvÓ&wÑ#ä×+Ñ+¬C¯J©J°zÈÔ,NÈtÒUVÈwÑ,WÐZdÐfpÐYqÓrˆLð  /Ø.Ø&4Ø&=Ø$0ñ
ð 	
r0   c                 óL   — |j                   |d<   |d   d d …dd …f   dz   |d<   |S )Nrl  r8  r'   r    )rl  )rT   Úmodel_outputsÚmodel_kwargss      r.   Úupdate_inputs_for_generationzCFlaxBlenderbotForConditionalGeneration.update_inputs_for_generationÁ  s?   € Ø*7×*GÑ*GˆÐ&Ñ'Ø/;Ð<RÑ/SÒTUÐWYÑWZÐTZÑ/[Ð^_Ñ/_ˆÐ+Ñ,ØÐr0   rv  rÿ   )r¤   r¥   r¦   r€  r?  r(   rª   r:   r§   r   rz  r   r   r!   r   r¬   ry  rA   r   rt  rG   ÚArrayrœ  r   ri   r0   r.   r•  r•    s9  … ð @€LØ—{‘{€Eˆ3�9‰9Ó"áÐ<Ó=ÙÐ+PÐ_oÔpð
 9=Ø8<Ø6:Ø $Ø,0Ø/3Ø&*ØØØ#ñEð !)¨¯©Ñ 5ð	Eð
 !)¨¯©Ñ 5ðEð ' s§{¡{Ñ3ðEð ðEð $ D™>ðEð ' t™nðEð ˜d‘^ðEð ðEð ðEð òEó qó >ðEðV /3Ø6:Øñ
ð ! §¡Ñ+ð	
ð
 !)¨¯©Ñ 3ó
ó>r0   r•  aî  
    Returns:

    Conversation example::

    ```py
    >>> from transformers import AutoTokenizer, FlaxBlenderbotForConditionalGeneration

    >>> model = FlaxBlenderbotForConditionalGeneration.from_pretrained("facebook/blenderbot-400M-distill")
    >>> tokenizer = AutoTokenizer.from_pretrained("facebook/blenderbot-400M-distill")

    >>> UTTERANCE = "My friends are cool but they eat too many carbs."
    >>> inputs = tokenizer([UTTERANCE], max_length=1024, return_tensors="np")

    >>> # Generate Reply
    >>> reply_ids = model.generate(inputs["input_ids"], num_beams=4, max_length=5, early_stopping=True).sequences
    >>> print([tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=False) for g in reply_ids])
    ```
rb  )r•  r~  r<  )LÚ__doc__r  ræ   Ú	functoolsr   Útypingr   r   r   Ú
flax.linenÚlinenrE   rG   Ú	jax.numpyÚnumpyr(   Úflax.core.frozen_dictr   r   r	   r
   r   Úflax.linen.attentionr   Úflax.traverse_utilr   r   r   Ú
jax.randomr   Úmodeling_flax_outputsr   r   r   r   r   Úmodeling_flax_utilsr   r   r   r   r   Úutilsr   r   r   r   Úconfiguration_blenderbotr!   Ú
get_loggerr¤   ÚloggerÚ_CONFIG_FOR_DOCÚ_CHECKPOINT_FOR_DOCÚBLENDERBOT_START_DOCSTRINGr{  rx  rz  r¬   r¨   r/   rw  r2   r®   rÊ   rî   rú   r  r  r&  r<  r~  r€  r•  Ú0FLAX_BLENDERBOT_CONDITIONAL_GENERATION_DOCSTRINGÚ__all__ri   r0   r.   ú<module>r¸     s  ðñ ã Û Ý ß ,Ñ ,å Û 
Ý ß >Ñ >ß 6Ý >ß ;Ý Ý ÷õ ÷õ ÷ uÓ tÝ 6ð 
ˆ×	Ñ	˜HÓ	%€à$€Ø8Ð ðÐ ð,0Ð ðf&Ð "ð<,&Ð "ð`	 #§+¡+ð 	¸Sð 	ÐZ]ð 	Ðbe×bmÑbmó 	ôd)˜bŸi™iô d)ôP5 §¡ô 5ôr3
¨2¯9©9ô 3
ônU §¡ô UôrC
¨2¯9©9ô C
ôLB
˜BŸI™Iô B
ôJL
˜BŸI™Iô L
ô`C
˜2Ÿ9™9ô C
ôLK
Ð$7ô K
ñ\
 ØeØóô(Ð7ó (ó	ð(ñ Ð0Ð2EÐG]Ð_nÔ oôE
°2·9±9ô E
ñP ØXÐZtóôoÐ-Jó oóðoðd4Ð 0ñ( Ø*ØÐ"RÑRôñ !Ø*Ð8KÐZiõò
 m�r0   