
    fThI                         S r SSKJr  SSKJrJrJr  SSKJr  SSK	J
r
  SSKJrJr  SSKJrJrJr  SS	KJr  SS
KJr  \R,                  " \5      r " S S\
5      r " S S\5      rSS/rg)zBlenderbot model configuration    )OrderedDict)AnyMappingOptional   )PreTrainedTokenizer)PretrainedConfig)
TensorTypeis_torch_available)
OnnxConfigOnnxConfigWithPastOnnxSeq2SeqConfigWithPast) compute_effective_axis_dimension)loggingc                   v   ^  \ rS rSrSrSrS/rSSS.r                         S
U 4S jjrS	r	U =r
$ )BlenderbotConfig   a  
This is the configuration class to store the configuration of a [`BlenderbotModel`]. It is used to instantiate an
Blenderbot model according to the specified arguments, defining the model architecture. Instantiating a
configuration with the defaults will yield a similar configuration to that of the Blenderbot
[facebook/blenderbot-3B](https://huggingface.co/facebook/blenderbot-3B) architecture.

Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
documentation from [`PretrainedConfig`] for more information.


Args:
    vocab_size (`int`, *optional*, defaults to 50265):
        Vocabulary size of the Blenderbot model. Defines the number of different tokens that can be represented by
        the `inputs_ids` passed when calling [`BlenderbotModel`] or [`TFBlenderbotModel`].
    d_model (`int`, *optional*, defaults to 1024):
        Dimensionality of the layers and the pooler layer.
    encoder_layers (`int`, *optional*, defaults to 12):
        Number of encoder layers.
    decoder_layers (`int`, *optional*, defaults to 12):
        Number of decoder layers.
    encoder_attention_heads (`int`, *optional*, defaults to 16):
        Number of attention heads for each attention layer in the Transformer encoder.
    decoder_attention_heads (`int`, *optional*, defaults to 16):
        Number of attention heads for each attention layer in the Transformer decoder.
    decoder_ffn_dim (`int`, *optional*, defaults to 4096):
        Dimensionality of the "intermediate" (often named feed-forward) layer in decoder.
    encoder_ffn_dim (`int`, *optional*, defaults to 4096):
        Dimensionality of the "intermediate" (often named feed-forward) layer in decoder.
    activation_function (`str` or `function`, *optional*, defaults to `"gelu"`):
        The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
        `"relu"`, `"silu"` and `"gelu_new"` are supported.
    dropout (`float`, *optional*, defaults to 0.1):
        The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
    attention_dropout (`float`, *optional*, defaults to 0.0):
        The dropout ratio for the attention probabilities.
    activation_dropout (`float`, *optional*, defaults to 0.0):
        The dropout ratio for activations inside the fully connected layer.
    max_position_embeddings (`int`, *optional*, defaults to 128):
        The maximum sequence length that this model might ever be used with. Typically set this to something large
        just in case (e.g., 512 or 1024 or 2048).
    init_std (`float`, *optional*, defaults to 0.02):
        The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
    encoder_layerdrop (`float`, *optional*, defaults to 0.0):
        The LayerDrop probability for the encoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556)
        for more details.
    decoder_layerdrop (`float`, *optional*, defaults to 0.0):
        The LayerDrop probability for the decoder. See the [LayerDrop paper](see https://arxiv.org/abs/1909.11556)
        for more details.
    scale_embedding (`bool`, *optional*, defaults to `False`):
        Scale embeddings by diving by sqrt(d_model).
    use_cache (`bool`, *optional*, defaults to `True`):
        Whether or not the model should return the last key/values attentions (not used by all models)
    forced_eos_token_id (`int`, *optional*, defaults to 2):
        The id of the token to force as the last generated token when `max_length` is reached. Usually set to
        `eos_token_id`.

Example:

```python
>>> from transformers import BlenderbotConfig, BlenderbotModel

>>> # Initializing a Blenderbot facebook/blenderbot-3B style configuration
>>> configuration = BlenderbotConfig()

>>> # Initializing a model (with random weights) from the facebook/blenderbot-3B style configuration
>>> model = BlenderbotModel(configuration)

>>> # Accessing the model configuration
>>> configuration = model.config
```
blenderbotpast_key_valuesencoder_attention_headsd_model)num_attention_headshidden_sizec                 "  > Xl         X l        Xl        X@l        X0l        XPl        Xpl        X`l        Xl        Xl	        UU l
        UU l        Xl        UU l        Xl        Xl        Xl        X0l        UU l        [&        TU ]P  " SUUUUUUUS.UD6  g )N)pad_token_idbos_token_ideos_token_idis_encoder_decoderdecoder_start_token_idencoder_no_repeat_ngram_sizeforced_eos_token_id )
vocab_sizemax_position_embeddingsr   encoder_ffn_dimencoder_layersr   decoder_ffn_dimdecoder_layersdecoder_attention_headsdropoutattention_dropoutactivation_dropoutactivation_functioninit_stdencoder_layerdropdecoder_layerdrop	use_cachenum_hidden_layersscale_embeddingsuper__init__)selfr#   r$   r&   r%   r   r(   r'   r)   r/   r0   r1   r   r-   r   r*   r+   r,   r.   r   r3   r   r   r   r    r!   kwargs	__class__s                              o/var/www/auris/envauris/lib/python3.13/site-packages/transformers/models/blenderbot/configuration_blenderbot.pyr5   BlenderbotConfig.__init__k   s    : %'>$.,'>$.,'>$!2"4#6  !2!2"!/. 		
%%%1#9)E 3		
 		
    )r,   r-   r+   r   r)   r'   r0   r(   r*   r   r%   r/   r&   r.   r$   r2   r3   r1   r#   )iH         (         r>   r?           rA   TTgelui 
  g?rA   rA   g{Gz?   Fr   rC   r=   r   r=   )__name__
__module____qualname____firstlineno____doc__
model_typekeys_to_ignore_at_inferenceattribute_mapr5   __static_attributes____classcell__r8   s   @r9   r   r      s|    EN J#4"5,EV_`M  # " "" %&5:
 :
r;   r   c                     ^  \ rS rSr\S\\\\\4   4   4S j5       r\S\\\\\4   4   4U 4S jj5       r	    SS\
S\S\S\S	\\   S\\\4   4S
 jjr    SS\
S\S\S\S	\\   S\\\4   4S jjr    SS\
S\S\S\S	\\   S\\\4   4S jjr    SS\
S\S\S\S	\\   S\\\4   4S jjrU 4S jrS\\\\\4   4   S\4S jrSrU =r$ )BlenderbotOnnxConfig   returnc           	      &   U R                   S;   ak  [        SSSS.4SSSS.4/5      nU R                  (       a  SS0US'   SS	S.US
'   OSSS.US'   SSS.US
'   U R                  (       a  U R                  USS9  U$ U R                   S:X  ab  [        SSSS.4SSSS.4/5      nU R                  (       a8  U R                  u  p#[        U5       H  nSSS.USU S3'   SSS.USU S3'   M     U$ [        SSSS.4SSSS.4SSSS.4S
SSS.4/5      nU$ )Ndefaultz
seq2seq-lm	input_idsbatchencoder_sequence)r   rC   attention_maskr   decoder_input_ids past_decoder_sequence + sequencedecoder_attention_maskdecoder_sequenceinputs)	direction	causal-lmpast_sequence + sequencer   r=   zpast_key_values..key.value)taskr   use_pastfill_with_past_key_values_
num_layersrange)r6   common_inputs_num_decoder_layersis        r9   r^   BlenderbotOnnxConfig.inputs   s   9911' g2D"EF%77I'JKM }}67\12>EJl:m679@EW5X12>EJ\:]67}}///R. - YY+%' g2D"EF%77I'JKM }}(,%12ADKPj@kM$4QCt"<=FMRlBmM$4QCv">? 3  ( g2D"EF%77I'JK(g:L*MN-7?Q/RS	M r;   c                    > U R                   S;   a  [        TU ]  nU$ [        [        U ]
  nU R                  (       a8  U R
                  u  p#[        U5       H  nSSS.USU S3'   SSS.USU S3'   M     U$ )NrT   rW   ra   rb   zpresent.rc   rd   )re   r4   outputsr   rf   rh   ri   )r6   common_outputsnum_encoder_layersrk   rm   r8   s        r9   rp   BlenderbotOnnxConfig.outputs   s     9911"W_N  ##5tDN}}(,%"12A=DIc9dNXaS#56?FKe;fNXaS#78 3 r;   	tokenizer
batch_size
seq_lengthis_pair	frameworkc           	      r   U R                  XX4U5      nU R                  (       d  UOSnU R                  XXtU5      nUR                  5        V	V
s0 s H  u  pSU	 3U
_M     nn	n
[        S
0 UDUD6nU R                  (       Ga.  [	        5       (       d  [        S5      eSS KnUS   R                  u  pUS   R                  S   nU R                  u  nnUUUU R                  R                  U-  4nUnUUUU R                  R                  U-  4nUR                  US   UR                  UU5      /SS9US'   / US	'   U R                  u  nn[        U5       HW  nUS	   R                  UR!                  U5      UR!                  U5      UR!                  U5      UR!                  U5      45        MY     U$ s  sn
n	f )NrC   decoder_ACannot generate dummy past_keys inputs without PyTorch installed.r   rV   rZ   r\   dimr   r"   )I_generate_dummy_inputs_for_sequence_classification_and_question_answeringrf   itemsdictr   
ValueErrortorchshaper   _configr   catonesrh   ri   appendzeros)r6   rt   ru   rv   rw   rx   encoder_inputsdecoder_seq_lengthdecoder_inputsnametensorrj   r   rW   encoder_seq_lengthnum_encoder_attention_headsnum_decoder_attention_headsencoder_shapedecoder_past_lengthdecoder_shaperk   rl   s                         r9   1_generate_dummy_inputs_for_default_and_seq2seq_lmFBlenderbotOnnxConfig._generate_dummy_inputs_for_default_and_seq2seq_lm   s    gg:	
 04}}Z!gg#5	
 IWH\H\H^_H^HTF+V3H^_@~@@===%'' !dee(5k(B(H(H%E!./B!C!I!I!!LGKG_G_D')D+"((,GG	M #5+#((,GG	M 7<ii78%**UL_:`agh 7@ 7M23 02M+,$(OO!A!-./077M2M2M2M2	 / O `s   F3c           	         U R                  XX4U5      nU R                  (       a  [        5       (       d  [        S5      eSS KnUS   R
                  u  pU	n
U R                  u  pU R                  u  pUUU
U R                  R                  U-  4nUS   R                  nUR                  US   UR                  XUS9/SS9US'   [        U5       Vs/ s H$  oR                  U5      UR                  U5      4PM&     snUS'   U$ s  snf )	Nr{   r   rV   rY   )dtyperC   r|   r   )r~   rf   r   r   r   r   rh   r   r   r   r   r   r   ri   r   )r6   rt   ru   rv   rw   rx   rj   r   rW   seqlenpast_key_values_lengthrk   rl   r   
past_shape
mask_dtypes                   r9   $_generate_dummy_inputs_for_causal_lm9BlenderbotOnnxConfig._generate_dummy_inputs_for_causal_lm  s)    ff:	
 ==%'' !dee)+6<<ME%+"$(OO!A-1-E-E*'+&((,GG	J ''78>>J.3ii/0%**Ubl*2mntu /8 /M*+ MRRdLe0LeqZ(%++j*ABLe0M+, 0s   +Dc                     [        U[        R                  SS9nUR                  U5      n[        U[        R                  US9nSR                  UR                  /5      U-  /U-  n[        U" XuS95      nU$ )Nr   )fixed_dimensionnum_token_to_add )return_tensors)r   r   default_fixed_batchnum_special_tokens_to_adddefault_fixed_sequencejoin	unk_tokenr   )	r6   rt   ru   rv   rw   rx   token_to_adddummy_inputrj   s	            r9   r~   ^BlenderbotOnnxConfig._generate_dummy_inputs_for_sequence_classification_and_question_answering>  s     6
(F(FYZ


 !::7C5
(I(I\h


 xx!4!4 56CDzQY{MNr;   c                     U R                   S;   a  U R                  XX4US9nU$ U R                   S:X  a  U R                  XX4US9nU$ U R                  XX4US9nU$ )NrT   )ru   rv   rw   rx   r`   )re   r   r   r~   )r6   rt   ru   rv   rw   rx   rj   s          r9   generate_dummy_inputs*BlenderbotOnnxConfig.generate_dummy_inputsY  s     9911 RRZdm S M  YY+% EEZdm F M 	 !jjZdm k M r;   c                 p   > U R                   S;   a  [        TU ]	  XX45      ng [        [        U ]  XX45      ng )NrT   )re   r4   _flatten_past_key_values_r   )r6   flattened_outputr   idxtr8   s        r9   r   .BlenderbotOnnxConfig._flatten_past_key_values_r  s<    9911$w@AQY\`$%>_  r;   inputs_or_outputsr_   c                    US;  a  [        SU S35      eUS:X  a  SOSnU R                  u  pESnUS:X  a  SOS	n[        U5       H7  nS
US.X SU S3'   S
US.X SU S3'   S
US.X SU S3'   S
US.X SU S3'   M9     g )N)r^   rp   z4direction must either be "inputs" or "outputs", but z
 was givenr^   r   presentpast_encoder_sequencepast_decoder_sequencer[   rW   rb   .z.decoder.keyz.decoder.valuez.encoder.keyz.encoder.value)r   rh   ri   )	r6   r   r_   r   rk   rl   rX   r]   rm   s	            r9   rg   /BlenderbotOnnxConfig.fill_with_past_key_values_z  s    11ST]S^^hijj$-$9 y $26?86K2Qs)*A?FK[;\as,78AHM]=^as.9:?FK[;\as,78AHM]=^as.9:	 +r;   r"   )r   FN)rD   rE   rF   rG   propertyr   strintr^   rp   r   boolr   r
   r   r   r   r~   r   r   rg   rL   rM   rN   s   @r9   rP   rP      s   &WS#X%6 67 & &P 
gc3h&7!78 
 
 *.7&7 7 	7
 7 J'7 
c	7x *."&" " 	"
 " J'" 
c	"P *.&  	
  J' 
c	< *.&  	
  J' 
c	2_GCQTVYQYIZDZ<[ _hk _ _r;   rP   N)rH   collectionsr   typingr   r   r    r   configuration_utilsr	   
file_utilsr
   r   onnxr   r   r   
onnx.utilsr   utilsr   
get_loggerrD   loggerr   rP   __all__r"   r;   r9   <module>r      si    % # ) ) # 3 8 M M :  
		H	%F
' F
R`_4 `_F 5
6r;   