Ë
    ÜÓ^jÇä  ã                   óÞ  — d Z ddlZddlmZ ddl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 dd	lmZ dd
lmZmZmZ ddlmZ  ej.                  e«      Z G d„ dej4                  «      Z ed¬«      e G d„ de«      «       «       Z ed¬«      e G d„ de«      «       «       Z ed¬«      e G d„ de«      «       «       Z G d„ dej4                  «      Z G d„ dej4                  «      Z  G d„ dej4                  «      Z! G d„ d ej4                  «      Z" G d!„ d"ej4                  «      Z# G d#„ d$ej4                  «      Z$ G d%„ d&ej4                  «      Z% G d'„ d(ej4                  «      Z& G d)„ d*ej4                  «      Z' G d+„ d,ej4                  «      Z( G d-„ d.ej4                  «      Z) G d/„ d0ej4                  «      Z* G d1„ d2ej4                  «      Z+ G d3„ d4ej4                  «      Z, G d5„ d6ej4                  «      Z- G d7„ d8ej4                  «      Z. G d9„ d:ej4                  «      Z/e G d;„ d<e«      «       Z0e G d=„ d>e0«      «       Z1e G d?„ d@e0«      «       Z2 edA¬«       G dB„ dCe0«      «       Z3g dD¢Z4y)EzPyTorch LXMERT model.é    N)Ú	dataclass)Únn)ÚCrossEntropyLossÚSmoothL1Lossé   )Úinitialization)ÚACT2FNÚgelu)ÚPreTrainedModel)ÚModelOutputÚauto_docstringÚloggingé   )ÚLxmertConfigc                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚGeLUc                 ó"   •— t         ‰| �  «        y ©N)ÚsuperÚ__init__)ÚselfÚ	__class__s    €úu/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/transformers/models/lxmert/modeling_lxmert.pyr   zGeLU.__init__"   s   ø€ Ü‰ÑÕó    c                 ó   — t        |«      S r   )r
   )r   Úxs     r   ÚforwardzGeLU.forward%   s   € Ü�A‹wˆr   ©Ú__name__Ú
__module__Ú__qualname__r   r   Ú__classcell__©r   s   @r   r   r   !   s   ø„ ôör   r   zÿ
    Lxmert's outputs that contain the last hidden states, pooled outputs, and attention probabilities for the language,
    visual, and, cross-modality encoders. (note: the visual encoder in Lxmert is referred to as the "relation-ship"
    encoder")
    )Úcustom_introc                   óp  — e Zd ZU dZdZej                  dz  ed<   dZej                  dz  ed<   dZ	ej                  dz  ed<   dZ
eej                     dz  ed<   dZeej                     dz  ed<   dZeej                     dz  ed<   dZeej                     dz  ed	<   dZeej                     dz  ed
<   y)ÚLxmertModelOutputa
  
    language_output (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
        Sequence of hidden-states at the output of the last layer of the language encoder.
    vision_output (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
        Sequence of hidden-states at the output of the last layer of the visual encoder.
    pooled_output (`torch.FloatTensor` of shape `(batch_size, hidden_size)`):
        Last layer hidden-state of the first token of the sequence (classification, CLS, token) further processed
        by a Linear layer and a Tanh activation function. The Linear
    language_hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
        Tuple of `torch.FloatTensor` (one for input features + one for the output of each cross-modality layer) of
        shape `(batch_size, sequence_length, hidden_size)`.
    vision_hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
        Tuple of `torch.FloatTensor` (one for input features + one for the output of each cross-modality layer) of
        shape `(batch_size, sequence_length, hidden_size)`.
    language_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
        Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
        sequence_length)`. Attentions weights after the attention softmax, used to compute the weighted average in
        the self-attention heads.
    vision_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
        Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
        sequence_length)`. Attentions weights after the attention softmax, used to compute the weighted average in
        the self-attention heads.
    cross_encoder_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
        Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
        sequence_length)`. Attentions weights after the attention softmax, used to compute the weighted average in
        the self-attention heads.
    NÚlanguage_outputÚvision_outputÚpooled_outputÚlanguage_hidden_statesÚvision_hidden_statesÚlanguage_attentionsÚvision_attentionsÚcross_encoder_attentions)r   r    r!   Ú__doc__r'   ÚtorchÚFloatTensorÚ__annotations__r(   r)   r*   Útupler+   r,   r-   r.   © r   r   r&   r&   )   sÏ   … ñð8 15€O�U×&Ñ&¨Ñ-Ó4Ø.2€M�5×$Ñ$ tÑ+Ó2Ø.2€M�5×$Ñ$ tÑ+Ó2Ø>BÐ˜E %×"3Ñ"3Ñ4°tÑ;ÓBØ<@Ð˜% × 1Ñ 1Ñ2°TÑ9Ó@Ø;?Ð˜˜u×0Ñ0Ñ1°DÑ8Ó?Ø9=Ð�u˜U×.Ñ.Ñ/°$Ñ6Ó=Ø@DÐ˜e E×$5Ñ$5Ñ6¸Ñ=ÔDr   r&   z8
    Output type of [`LxmertForQuestionAnswering`].
    c                   óH  — e Zd ZU dZdZej                  dz  ed<   dZej                  dz  ed<   dZ	e
ej                     dz  ed<   dZe
ej                     dz  ed<   dZe
ej                     dz  ed<   dZe
ej                     dz  ed<   dZe
ej                     dz  ed	<   y)
Ú LxmertForQuestionAnsweringOutputa	  
    loss (*optional*, returned when `labels` is provided, `torch.FloatTensor` of shape `(1,)`):
        Total loss as the sum of the masked language modeling loss and the next sequence prediction
        (classification) loss.k.
    question_answering_score (`torch.FloatTensor` of shape `(batch_size, n_qa_answers)`, *optional*):
        Prediction scores of question answering objective (classification).
    language_hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
        Tuple of `torch.FloatTensor` (one for input features + one for the output of each cross-modality layer) of
        shape `(batch_size, sequence_length, hidden_size)`.
    vision_hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
        Tuple of `torch.FloatTensor` (one for input features + one for the output of each cross-modality layer) of
        shape `(batch_size, sequence_length, hidden_size)`.
    language_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
        Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
        sequence_length)`. Attentions weights after the attention softmax, used to compute the weighted average in
        the self-attention heads.
    vision_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
        Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
        sequence_length)`. Attentions weights after the attention softmax, used to compute the weighted average in
        the self-attention heads.
    cross_encoder_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
        Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
        sequence_length)`. Attentions weights after the attention softmax, used to compute the weighted average in
        the self-attention heads.
    NÚlossÚquestion_answering_scorer*   r+   r,   r-   r.   )r   r    r!   r/   r7   r0   r1   r2   r8   r*   r3   r+   r,   r-   r.   r4   r   r   r6   r6   X   s»   … ñð4 &*€Dˆ%×
Ñ
˜dÑ
"Ó)Ø9=Ð˜e×/Ñ/°$Ñ6Ó=Ø>BÐ˜E %×"3Ñ"3Ñ4°tÑ;ÓBØ<@Ð˜% × 1Ñ 1Ñ2°TÑ9Ó@Ø;?Ð˜˜u×0Ñ0Ñ1°DÑ8Ó?Ø9=Ð�u˜U×.Ñ.Ñ/°$Ñ6Ó=Ø@DÐ˜e E×$5Ñ$5Ñ6¸Ñ=ÔDr   r6   z2
    Output type of [`LxmertForPreTraining`].
    c                   ó˜  — e Zd ZU dZdZej                  dz  ed<   dZej                  dz  ed<   dZ	ej                  dz  ed<   dZ
ej                  dz  ed<   dZeej                     dz  ed<   dZeej                     dz  ed<   dZeej                     dz  ed	<   dZeej                     dz  ed
<   dZeej                     dz  ed<   y)ÚLxmertForPreTrainingOutputaÂ
  
    loss (*optional*, returned when `labels` is provided, `torch.FloatTensor` of shape `(1,)`):
        Total loss as the sum of the masked language modeling loss and the next sequence prediction
        (classification) loss.
    prediction_logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):
        Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
    cross_relationship_score (`torch.FloatTensor` of shape `(batch_size, 2)`):
        Prediction scores of the textual matching objective (classification) head (scores of True/False
        continuation before SoftMax).
    question_answering_score (`torch.FloatTensor` of shape `(batch_size, n_qa_answers)`):
        Prediction scores of question answering objective (classification).
    language_hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
        Tuple of `torch.FloatTensor` (one for input features + one for the output of each cross-modality layer) of
        shape `(batch_size, sequence_length, hidden_size)`.
    vision_hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
        Tuple of `torch.FloatTensor` (one for input features + one for the output of each cross-modality layer) of
        shape `(batch_size, sequence_length, hidden_size)`.
    language_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
        Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
        sequence_length)`. Attentions weights after the attention softmax, used to compute the weighted average in
        the self-attention heads.
    vision_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
        Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
        sequence_length)`. Attentions weights after the attention softmax, used to compute the weighted average in
        the self-attention heads.
    cross_encoder_attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
        Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
        sequence_length)`. Attentions weights after the attention softmax, used to compute the weighted average in
        the self-attention heads.
    Nr7   Úprediction_logitsÚcross_relationship_scorer8   r*   r+   r,   r-   r.   )r   r    r!   r/   r7   r0   r1   r2   r;   r<   r8   r*   r3   r+   r,   r-   r.   r4   r   r   r:   r:   ‚   sç   … ñð> &*€Dˆ%×
Ñ
˜dÑ
"Ó)Ø26Ð�u×(Ñ(¨4Ñ/Ó6Ø9=Ð˜e×/Ñ/°$Ñ6Ó=Ø9=Ð˜e×/Ñ/°$Ñ6Ó=Ø>BÐ˜E %×"3Ñ"3Ñ4°tÑ;ÓBØ<@Ð˜% × 1Ñ 1Ñ2°TÑ9Ó@Ø;?Ð˜˜u×0Ñ0Ñ1°DÑ8Ó?Ø9=Ð�u˜U×.Ñ.Ñ/°$Ñ6Ó=Ø@DÐ˜e E×$5Ñ$5Ñ6¸Ñ=ÔDr   r:   c                   ó*   ‡ — e Zd ZdZˆ fd„Zdd„Zˆ xZS )ÚLxmertEmbeddingszGConstruct the embeddings from word, position and token_type embeddings.c                 óÜ  •— t         ‰| �  «        t        j                  |j                  |j
                  d¬«      | _        t        j                  |j                  |j
                  d¬«      | _        t        j                  |j                  |j
                  d¬«      | _
        t        j                  |j
                  d¬«      | _        t        j                  |j                  «      | _        y )Nr   )Úpadding_idxçê-�™—q=©Úeps)r   r   r   Ú	EmbeddingÚ
vocab_sizeÚhidden_sizeÚword_embeddingsÚmax_position_embeddingsÚposition_embeddingsÚtype_vocab_sizeÚtoken_type_embeddingsÚ	LayerNormÚDropoutÚhidden_dropout_probÚdropout©r   Úconfigr   s     €r   r   zLxmertEmbeddings.__init__¶   s£   ø€ Ü‰ÑÔÜ!Ÿ|™|¨F×,=Ñ,=¸v×?QÑ?QÐ_`ÔaˆÔÜ#%§<¡<°×0NÑ0NÐPV×PbÑPbÐpqÔ#rˆÔ Ü%'§\¡\°&×2HÑ2HÈ&×J\ÑJ\ÐjkÔ%lˆÔ"äŸ™ f×&8Ñ&8¸eÔDˆŒÜ—z‘z &×"<Ñ"<Ó=ˆ�r   c                 óN  — |�|j                  «       }|j                  }n|j                  «       d d }|j                  }|d   }t        j                  |t        j                  |¬«      }|j                  d«      j                  |«      }|€:t        j                  |t        j                  | j                  j                  ¬«      }|€| j                  |«      }| j                  |«      }| j                  |«      }	||z   |	z   }
| j                  |
«      }
| j                  |
«      }
|
S )Néÿÿÿÿr   ©ÚdtypeÚdevicer   )ÚsizerV   r0   ÚarangeÚlongÚ	unsqueezeÚexpandÚzerosÚposition_idsrG   rI   rK   rL   rO   )r   Ú	input_idsÚtoken_type_idsÚinputs_embedsÚinput_shaperV   Ú
seq_lengthr]   rI   rK   Ú
embeddingss              r   r   zLxmertEmbeddings.forward¿   s  € ØÐ Ø#Ÿ.™.Ó*ˆKØ×%Ñ%‰Fà'×,Ñ,Ó.¨s°Ð3ˆKØ"×)Ñ)ˆFØ  ‘^ˆ
ä—|‘| J´e·j±jÈÔPˆØ#×-Ñ-¨aÓ0×7Ñ7¸ÓDˆàÐ!Ü"Ÿ[™[¨¼E¿J¹JÈt×O`ÑO`×OgÑOgÔhˆNàÐ Ø ×0Ñ0°Ó;ˆMØ"×6Ñ6°|ÓDÐØ $× :Ñ :¸>Ó JÐà"Ð%8Ñ8Ð;PÑPˆ
Ø—^‘^ JÓ/ˆ
Ø—\‘\ *Ó-ˆ
ØÐr   ©NN)r   r    r!   r/   r   r   r"   r#   s   @r   r>   r>   ³   s   ø„ ÙQô>÷r   r>   c                   ó(   ‡ — e Zd Zdˆ fd„	Zdd„Zˆ xZS )ÚLxmertAttentionc                 ó¨  •— t         ‰| �  «        |j                  |j                  z  dk7  r&t	        d|j                  › d|j                  › d�«      ‚|j                  | _        t        |j                  |j                  z  «      | _        | j                  | j                  z  | _        |€|j                  }t        j                  |j                  | j                  «      | _
        t        j                  || j                  «      | _        t        j                  || j                  «      | _        t        j                  |j                  «      | _        y )Nr   zThe hidden size (z6) is not a multiple of the number of attention heads (ú))r   r   rF   Únum_attention_headsÚ
ValueErrorÚintÚattention_head_sizeÚ	head_sizer   ÚLinearÚqueryÚkeyÚvaluerM   Úattention_probs_dropout_probrO   )r   rQ   Úctx_dimr   s      €r   r   zLxmertAttention.__init__Ú   s  ø€ Ü‰ÑÔØ×Ñ × :Ñ :Ñ:¸aÒ?ÜØ# F×$6Ñ$6Ð#7ð 8Ø ×4Ñ4Ð5°Qð8óð ð $*×#=Ñ#=ˆÔ Ü#& v×'9Ñ'9¸F×<VÑ<VÑ'VÓ#WˆÔ Ø×1Ñ1°D×4LÑ4LÑLˆŒð ˆ?Ø×(Ñ(ˆGÜ—Y‘Y˜v×1Ñ1°4·>±>ÓBˆŒ
Ü—9‘9˜W d§n¡nÓ5ˆŒÜ—Y‘Y˜w¨¯©Ó7ˆŒ
ä—z‘z &×"EÑ"EÓFˆ�r   c                 ó–  — |j                   d d }g |¢d‘| j                  ‘­}| j                  |«      j                  |«      j	                  dd«      }g |j                   d d ¢d‘| j                  ‘­}| j                  |«      j                  |«      j	                  dd«      }	| j                  |«      j                  |«      j	                  dd«      }
t        j                  ||	j	                  dd«      «      }|t        j                  | j                  «      z  }|�||z   }t        j                  j                  |d¬«      }| j                  |«      }t        j                  ||
«      }|j                  dddd«      j!                  «       }|j#                  «       d d | j$                  fz   }|j                  |«      }|r||f}|S |f}|S )NrS   r   é   éþÿÿÿ)Údimr   r   )Úshaperl   ro   ÚviewÚ	transposerp   rq   r0   ÚmatmulÚmathÚsqrtr   Ú
functionalÚsoftmaxrO   ÚpermuteÚ
contiguousrW   rm   )r   Úhidden_statesÚcontextÚattention_maskÚoutput_attentionsra   Úhidden_shapeÚquery_layerÚkv_shapeÚ	key_layerÚvalue_layerÚattention_scoresÚattention_probsÚcontext_layerÚnew_context_layer_shapeÚoutputss                   r   r   zLxmertAttention.forwardî   sÁ  € Ø#×)Ñ)¨#¨2Ð.ˆØC˜ÐC bÐC¨$×*BÑ*BÑCˆØ—j‘j Ó/×4Ñ4°\ÓB×LÑLÈQÐPQÓRˆØF�W—]‘] 3 BÐ'ÐF¨ÐF¨T×-EÑ-EÑFˆØ—H‘H˜WÓ%×*Ñ*¨8Ó4×>Ñ>¸qÀ!ÓDˆ	Ø—j‘j Ó)×.Ñ.¨xÓ8×BÑBÀ1ÀaÓHˆô !Ÿ<™<¨°Y×5HÑ5HÈÈRÓ5PÓQÐØ+¬d¯i©i¸×8PÑ8PÓ.QÑQÐàÐ%Ø/°.Ñ@Ðô Ÿ-™-×/Ñ/Ð0@ÀbÐ/ÓIˆð Ÿ,™, Ó7ˆäŸ™ _°kÓBˆØ%×-Ñ-¨a°°A°qÓ9×DÑDÓFˆØ"/×"4Ñ"4Ó"6°s¸Ð";¸t¿~¹~Ð>OÑ"OÐØ%×*Ñ*Ð+BÓCˆá6G�= /Ð2ˆØˆð O\ÐM]ˆØˆr   r   ©NFr   r#   s   @r   rf   rf   Ù   s   ø„ õG÷(r   rf   c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLxmertAttentionOutputc                 ó  •— t         ‰| �  «        t        j                  |j                  |j                  «      | _        t        j                  |j                  d¬«      | _        t        j                  |j                  «      | _	        y ©NrA   rB   )
r   r   r   rn   rF   ÚdenserL   rM   rN   rO   rP   s     €r   r   zLxmertAttentionOutput.__init__  sZ   ø€ Ü‰ÑÔÜ—Y‘Y˜v×1Ñ1°6×3EÑ3EÓFˆŒ
ÜŸ™ f×&8Ñ&8¸eÔDˆŒÜ—z‘z &×"<Ñ"<Ó=ˆ�r   c                 ór   — | j                  |«      }| j                  |«      }| j                  ||z   «      }|S r   ©r•   rO   rL   ©r   r‚   Úinput_tensors      r   r   zLxmertAttentionOutput.forward  ó7   € ØŸ
™
 =Ó1ˆØŸ™ ]Ó3ˆØŸ™ }°|Ñ'CÓDˆØÐr   r   r#   s   @r   r’   r’     ó   ø„ ô>ör   r’   c                   ó&   ‡ — e Zd Zˆ fd„Zdd„Zˆ xZS )ÚLxmertCrossAttentionLayerc                 ób   •— t         ‰| �  «        t        |«      | _        t	        |«      | _        y r   )r   r   rf   Úattr’   ÚoutputrP   s     €r   r   z"LxmertCrossAttentionLayer.__init__  s&   ø€ Ü‰ÑÔÜ" 6Ó*ˆŒÜ+¨FÓ3ˆ�r   c                 ó~   — | j                  ||||¬«      }|r|d   }| j                  |d   |«      }|r|f}|S |f}|S ©N©r…   r   r   )rŸ   r    )	r   r™   Ú
ctx_tensorÚctx_att_maskr…   r    rŒ   Úattention_outputr�   s	            r   r   z!LxmertCrossAttentionLayer.forward!  s]   € Ø—‘˜,¨
°LÐTe�ÓfˆÙØ$ Q™iˆOØŸ;™; v¨a¡y°,Ó?ÐÙ9JÐ# _Ð5ˆØˆð RbÐPcˆØˆr   r�   r   r#   s   @r   r�   r�     s   ø„ ô4÷
r   r�   c                   ó&   ‡ — e Zd Zˆ fd„Zdd„Zˆ xZS )ÚLxmertSelfAttentionLayerc                 ób   •— t         ‰| �  «        t        |«      | _        t	        |«      | _        y r   )r   r   rf   r   r’   r    rP   s     €r   r   z!LxmertSelfAttentionLayer.__init__+  s&   ø€ Ü‰ÑÔÜ# FÓ+ˆŒ	Ü+¨FÓ3ˆ�r   c                 ó~   — | j                  ||||¬«      }|r|d   }| j                  |d   |«      }|r|f}|S |f}|S r¢   )r   r    )r   r™   r„   r…   r    rŒ   r¦   r�   s           r   r   z LxmertSelfAttentionLayer.forward0  sg   € à—‘ØØØØ/ð	 ó 
ˆñ Ø$ Q™iˆOØŸ;™; v¨a¡y°,Ó?ÐÙ9JÐ# _Ð5ˆØˆð RbÐPcˆØˆr   ©Fr   r#   s   @r   r¨   r¨   *  s   ø„ ô4÷
r   r¨   c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLxmertIntermediatec                 ó°   •— t         ‰| �  «        t        j                  |j                  |j
                  «      | _        t        |j                     | _	        y r   )
r   r   r   rn   rF   Úintermediate_sizer•   r	   Ú
hidden_actÚintermediate_act_fnrP   s     €r   r   zLxmertIntermediate.__init__@  s?   ø€ Ü‰ÑÔÜ—Y‘Y˜v×1Ñ1°6×3KÑ3KÓLˆŒ
Ü#)¨&×*;Ñ*;Ñ#<ˆÕ r   c                 óJ   — | j                  |«      }| j                  |«      }|S r   )r•   r±   ©r   r‚   s     r   r   zLxmertIntermediate.forwardE  s&   € ØŸ
™
 =Ó1ˆØ×0Ñ0°Ó?ˆØÐr   r   r#   s   @r   r­   r­   ?  s   ø„ ô=ö
r   r­   c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLxmertOutputc                 ó  •— t         ‰| �  «        t        j                  |j                  |j
                  «      | _        t        j                  |j
                  d¬«      | _        t        j                  |j                  «      | _
        y r”   )r   r   r   rn   r¯   rF   r•   rL   rM   rN   rO   rP   s     €r   r   zLxmertOutput.__init__L  sZ   ø€ Ü‰ÑÔÜ—Y‘Y˜v×7Ñ7¸×9KÑ9KÓLˆŒ
ÜŸ™ f×&8Ñ&8¸eÔDˆŒÜ—z‘z &×"<Ñ"<Ó=ˆ�r   c                 ór   — | j                  |«      }| j                  |«      }| j                  ||z   «      }|S r   r—   r˜   s      r   r   zLxmertOutput.forwardR  rš   r   r   r#   s   @r   rµ   rµ   K  r›   r   rµ   c                   ó&   ‡ — e Zd Zˆ fd„Zdd„Zˆ xZS )ÚLxmertLayerc                 ó‚   •— t         ‰| �  «        t        |«      | _        t	        |«      | _        t        |«      | _        y r   )r   r   r¨   Ú	attentionr­   Úintermediaterµ   r    rP   s     €r   r   zLxmertLayer.__init__Z  s3   ø€ Ü‰ÑÔÜ1°&Ó9ˆŒÜ.¨vÓ6ˆÔÜ" 6Ó*ˆ�r   c                 ó�   — | j                  |||¬«      }|d   }| j                  |«      }| j                  ||«      }|f|dd  z   }|S )Nr£   r   r   )r»   r¼   r    )r   r‚   r„   r…   r�   r¦   Úintermediate_outputÚlayer_outputs           r   r   zLxmertLayer.forward`  s\   € Ø—.‘. °ÐRc�.ÓdˆØ" 1™:ÐØ"×/Ñ/Ð0@ÓAÐØ—{‘{Ð#6Ð8HÓIˆØ�/ G¨A¨B KÑ/ˆØˆr   r�   r   r#   s   @r   r¹   r¹   Y  s   ø„ ô+÷r   r¹   c                   ó>   ‡ — e Zd Zˆ fd„Z	 dd„Zd„ Zd„ Z	 dd„Zˆ xZS )ÚLxmertXLayerc                 ó  •— t         ‰| �  «        t        |«      | _        t	        |«      | _        t	        |«      | _        t        |«      | _        t        |«      | _
        t        |«      | _        t        |«      | _        y r   )r   r   r�   Úvisual_attentionr¨   Úlang_self_attÚvisn_self_attr­   Ú
lang_interrµ   Úlang_outputÚ
visn_interÚvisn_outputrP   s     €r   r   zLxmertXLayer.__init__j  sk   ø€ Ü‰ÑÔä 9¸&Ó AˆÔô 6°fÓ=ˆÔÜ5°fÓ=ˆÔô -¨VÓ4ˆŒÜ'¨Ó/ˆÔÜ,¨VÓ4ˆŒÜ'¨Ó/ˆÕr   c                 ó^   — | j                  ||||¬«      }| j                  |||d¬«      }||fS )N)r¥   r…   F)rÃ   )r   Ú
lang_inputÚlang_attention_maskÚvisual_inputÚvisual_attention_maskÚoutput_x_attentionsÚlang_att_outputÚvisual_att_outputs           r   Ú	cross_attzLxmertXLayer.cross_atty  sW   € ð ×/Ñ/ØØØ.Ø1ð	 0ó 
ˆð !×1Ñ1ØØØ,Ø#ð	 2ó 
Ðð Ð 1Ð1Ð1r   c                 óf   — | j                  ||d¬«      }| j                  ||d¬«      }|d   |d   fS )NFr£   r   )rÄ   rÅ   )r   rË   rÌ   rÍ   rÎ   rÐ   rÑ   s          r   Úself_attzLxmertXLayer.self_att�  sK   € à×,Ñ,¨ZÐ9LÐ`eÐ,ÓfˆØ ×.Ñ.¨|Ð=RÐfkÐ.ÓlÐØ˜qÑ!Ð#4°QÑ#7Ð7Ð7r   c                 ó–   — | j                  |«      }| j                  |«      }| j                  ||«      }| j                  ||«      }||fS r   )rÆ   rÈ   rÇ   rÉ   )r   rË   rÍ   Úlang_inter_outputÚvisual_inter_outputrÇ   Úvisual_outputs          r   Ú	output_fczLxmertXLayer.output_fc–  sS   € à ŸO™O¨JÓ7ÐØ"Ÿo™o¨lÓ;Ðð ×&Ñ&Ð'8¸*ÓEˆØ×(Ñ(Ð)<¸lÓKˆà˜MÐ)Ð)r   c                 ó¾   — | j                  |||||¬«      \  }}|dd  }| j                  |d   ||d   |«      \  }}| j                  ||«      \  }	}
|r|	|
|d   fS |	|
fS )N)rË   rÌ   rÍ   rÎ   rÏ   r   r   )rÒ   rÔ   rÙ   )r   Ú
lang_featsrÌ   Úvisual_featsrÎ   r…   rÐ   rÑ   rŒ   rÇ   rØ   s              r   r   zLxmertXLayer.forward¡  sª   € ð .2¯^©^Ø!Ø 3Ø%Ø"7Ø 1ð .<ó .
Ñ*ˆÐ*ð *¨!¨"Ð-ˆØ-1¯]©]Ø˜AÑØØ˜aÑ Ø!ó	.
Ñ*ˆÐ*ð &*§^¡^°OÐEVÓ%WÑ"ˆ�]ñ !ð	 ØØ Ñ"ðð	
ð ˜}Ð-ð	
r   r«   )	r   r    r!   r   rÒ   rÔ   rÙ   r   r"   r#   s   @r   rÁ   rÁ   i  s&   ø„ ô0ð* "ó2ò.8ò	*ð"  ÷ 
r   rÁ   c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLxmertVisualFeatureEncoderc                 óÆ  •— t         ‰| �  «        |j                  }|j                  }t	        j
                  ||j                  «      | _        t	        j                  |j                  d¬«      | _	        t	        j
                  ||j                  «      | _
        t	        j                  |j                  d¬«      | _        t	        j                  |j                  «      | _        y r”   )r   r   Úvisual_feat_dimÚvisual_pos_dimr   rn   rF   Úvisn_fcrL   Úvisn_layer_normÚbox_fcÚbox_layer_normrM   rN   rO   )r   rQ   Úfeat_dimÚpos_dimr   s       €r   r   z#LxmertVisualFeatureEncoder.__init__Å  s    ø€ Ü‰ÑÔØ×)Ñ)ˆØ×'Ñ'ˆô —y‘y ¨6×+=Ñ+=Ó>ˆŒÜ!Ÿ|™|¨F×,>Ñ,>ÀEÔJˆÔô —i‘i ¨×);Ñ);Ó<ˆŒÜ Ÿl™l¨6×+=Ñ+=À5ÔIˆÔä—z‘z &×"<Ñ"<Ó=ˆ�r   c                 óÀ   — | j                  |«      }| j                  |«      }| j                  |«      }| j                  |«      }||z   dz  }| j	                  |«      }|S ©Nru   )râ   rã   rä   rå   rO   )r   rÜ   Ú
visual_posr   Úyr    s         r   r   z"LxmertVisualFeatureEncoder.forwardÔ  s^   € Ø�L‰L˜Ó&ˆØ× Ñ  Ó#ˆØ�K‰K˜
Ó#ˆØ×Ñ Ó"ˆØ�a‘%˜1‘ˆà—‘˜fÓ%ˆØˆr   r   r#   s   @r   rÞ   rÞ   Ä  s   ø„ ô>ör   rÞ   c                   ó*   ‡ — e Zd Zˆ fd„Z	 	 dd„Zˆ xZS )ÚLxmertEncoderc                 ól  •— t         ‰| �  «        t        |«      | _        || _        |j
                  | _        |j                  | _        |j                  | _
        t        j                  t        | j                  «      D �cg c]  }t        |«      ‘Œ c}«      | _        t        j                  t        | j                  «      D �cg c]  }t!        |«      ‘Œ c}«      | _        t        j                  t        | j                  «      D �cg c]  }t        |«      ‘Œ c}«      | _	        y c c}w c c}w c c}w r   )r   r   rÞ   râ   rQ   Úl_layersÚnum_l_layersÚx_layersÚnum_x_layersÚr_layersÚnum_r_layersr   Ú
ModuleListÚranger¹   ÚlayerrÁ   )r   rQ   Ú_r   s      €r   r   zLxmertEncoder.__init__à  sØ   ø€ Ü‰ÑÔô 2°&Ó9ˆŒØˆŒð #ŸO™OˆÔØ"ŸO™OˆÔØ"ŸO™OˆÔô —]‘]ÄÀt×GXÑGXÓAYÖ#Z¸A¤K°Õ$7Ò#ZÓ[ˆŒ
ÜŸ™ÄUÈ4×K\ÑK\ÓE]Ö&^À¤|°FÕ';Ò&^Ó_ˆŒÜŸ™ÄEÈ$×J[ÑJ[ÓD\Ö&]¸q¤{°6Õ':Ò&]Ó^ˆ�ùò $[ùÚ&^ùÚ&]s   Â D'ÃD,ÄD1c                 óR  — d}d}|s| j                   j                  rdnd }	|s| j                   j                  rdnd }
|s| j                   j                  rdnd }| j                  ||«      }| j                  D ]$  } ||||¬«      }|d   }||fz   }|
€Œ|
|d   fz   }
Œ& | j                  D ]$  } ||||¬«      }|d   }||fz   }|	€Œ|	|d   fz   }	Œ& | j
                  D ]/  } ||||||¬«      }|d d \  }}||fz   }||fz   }|€Œ'||d   fz   }Œ1 ||r|	nd f}||r|
nd f}|||r|fS d fS )Nr4   r£   r   r   ru   )rQ   r…   râ   r÷   ró   rñ   )r   rÛ   rÌ   rÜ   rê   rÎ   r…   r+   r*   r-   r,   r.   Úlayer_moduleÚ	l_outputsÚ	v_outputsÚ	x_outputsÚvisual_encoder_outputsÚlang_encoder_outputss                     r   r   zLxmertEncoder.forwardò  sÔ  € ð  "ÐØ!#ÐÙ"3°t·{±{×7TÒ7T™BÐZ^ÐÙ$5¸¿¹×9VÒ9V™bÐ\`ÐÙ):¸d¿k¹k×>[Ò>[¡2ÐaeÐ à—|‘| L°*Ó=ˆð !ŸJ™Jò 	LˆLÙ$ ZÐ1DÐXiÔjˆIØ" 1™ˆJØ%;¸z¸mÑ%KÐ"Ø"Ñ.Ø&9¸YÀq¹\¸OÑ&KÑ#ð	Lð !ŸM™Mò 	HˆLÙ$ \Ð3HÐ\mÔnˆIØ$ Q™<ˆLØ#7¸<¸/Ñ#IÐ Ø Ñ,Ø$5¸À1¹¸Ñ$GÑ!ð	Hð !ŸM™Mò 	VˆLÙ$ØØ#ØØ%Ø"3ôˆIð (1°°! }Ñ$ˆJ˜Ø#7¸<¸/Ñ#IÐ Ø%;¸z¸mÑ%KÐ"Ø'Ñ3Ø+CÀyÐQRÁ|ÀoÑ+UÑ(ð	Vð !Ù!2Ñ¸ð"
Ðð
 #Ù#4Ñ¸$ð 
Ðð
 #Ø Ù(9Ð$ð
ð 	
ð @Dð
ð 	
r   rd   r   r#   s   @r   rí   rí   ß  s   ø„ ô_ð0 #Ø÷;
r   rí   c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLxmertPoolerc                 ó²   •— t         ‰| �  «        t        j                  |j                  |j                  «      | _        t        j                  «       | _        y r   )r   r   r   rn   rF   r•   ÚTanhÚ
activationrP   s     €r   r   zLxmertPooler.__init__1  s9   ø€ Ü‰ÑÔÜ—Y‘Y˜v×1Ñ1°6×3EÑ3EÓFˆŒ
ÜŸ'™'›)ˆ�r   c                 ó\   — |d d …df   }| j                  |«      }| j                  |«      }|S )Nr   )r•   r  )r   r‚   Úfirst_token_tensorr)   s       r   r   zLxmertPooler.forward6  s6   € ð +ª1¨a¨4Ñ0ÐØŸ
™
Ð#5Ó6ˆØŸ™¨Ó6ˆØÐr   r   r#   s   @r   r  r  0  s   ø„ ô$ö
r   r  c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLxmertPredictionHeadTransformc                 óü   •— t         ‰| �  «        t        j                  |j                  |j                  «      | _        t        |j                     | _        t        j                  |j                  d¬«      | _	        y r”   )
r   r   r   rn   rF   r•   r	   r°   Útransform_act_fnrL   rP   s     €r   r   z&LxmertPredictionHeadTransform.__init__@  sW   ø€ Ü‰ÑÔÜ—Y‘Y˜v×1Ñ1°6×3EÑ3EÓFˆŒ
Ü & v×'8Ñ'8Ñ 9ˆÔÜŸ™ f×&8Ñ&8¸eÔDˆ�r   c                 ól   — | j                  |«      }| j                  |«      }| j                  |«      }|S r   )r•   r
  rL   r³   s     r   r   z%LxmertPredictionHeadTransform.forwardF  s4   € ØŸ
™
 =Ó1ˆØ×-Ñ-¨mÓ<ˆØŸ™ }Ó5ˆØÐr   r   r#   s   @r   r  r  ?  s   ø„ ôEör   r  c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLxmertLMPredictionHeadc                 ó  •— t         ‰| �  «        t        |«      | _        t	        j
                  |j                  |j                  d¬«      | _        t	        j                  t        j                  |j                  «      «      | _        y )NF©Úbias)r   r   r  Ú	transformr   rn   rF   rE   ÚdecoderÚ	Parameterr0   r\   r  rP   s     €r   r   zLxmertLMPredictionHead.__init__N  sY   ø€ Ü‰ÑÔÜ6°vÓ>ˆŒÜ—y‘y ×!3Ñ!3°V×5FÑ5FÈUÔSˆŒÜ—L‘L¤§¡¨V×->Ñ->Ó!?Ó@ˆ�	r   c                 ód   — | j                  |«      }| j                  |«      | j                  z   }|S r   )r  r  r  r³   s     r   r   zLxmertLMPredictionHead.forwardT  s-   € ØŸ™ }Ó5ˆØŸ™ ]Ó3°d·i±iÑ?ˆØÐr   r   r#   s   @r   r  r  M  s   ø„ ôAör   r  c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLxmertVisualAnswerHeadc           	      ó  •— t         ‰| �  «        |j                  }t        j                  t        j
                  ||dz  «      t        «       t        j                  |dz  d¬«      t        j
                  |dz  |«      «      | _        y )Nru   rA   rB   )	r   r   rF   r   Ú
Sequentialrn   r   rL   Úlogit_fc)r   rQ   Ú
num_labelsÚhid_dimr   s       €r   r   zLxmertVisualAnswerHead.__init__[  sd   ø€ Ü‰ÑÔØ×$Ñ$ˆÜŸ™Ü�I‰I�g˜w¨™{Ó+Ü‹FÜ�L‰L˜ 1™¨%Ô0Ü�I‰I�g ‘k :Ó.ó	
ˆ�r   c                 ó$   — | j                  |«      S r   )r  r³   s     r   r   zLxmertVisualAnswerHead.forwarde  s   € Ø�}‰}˜]Ó+Ð+r   r   r#   s   @r   r  r  Z  s   ø„ ô
ö,r   r  c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLxmertVisualObjHeadc                 óì  •— t         ‰| �  «        t        |«      | _        i }|j                  rd|j
                  dœ|d<   |j                  rd|j                  dœ|d<   |j                  rd|j                  f|j                  dœ|d<   || _
        t        j                  | j                  D �ci c]3  }|t        j                  |j                  | j                  |   d   «      “Œ5 c}«      | _        y c c}w )N©rS   )rx   ÚnumÚobjÚattrrS   Úfeatr!  )r   r   r  r  Úvisual_obj_lossÚnum_object_labelsÚvisual_attr_lossÚnum_attr_labelsÚvisual_feat_lossrà   Úvisual_lossesr   Ú
ModuleDictrn   rF   Údecoder_dict)r   rQ   r*  rp   r   s       €r   r   zLxmertVisualObjHead.__init__j  sâ   ø€ Ü‰ÑÔÜ6°vÓ>ˆŒàˆØ×!Ò!Ø-2¸6×;SÑ;SÑ#TˆM˜%Ñ Ø×"Ò"Ø.3¸F×<RÑ<RÑ$SˆM˜&Ñ!Ø×"Ò"à˜f×4Ñ4Ð5Ø×-Ñ-ñ%ˆM˜&Ñ!ð +ˆÔô ŸM™MØ[_×[mÑ[mÖnÐTWˆS”"—)‘)˜F×.Ñ.°×0BÑ0BÀ3Ñ0GÈÑ0NÓOÑOÒnó
ˆÕùÚns   Â,8C1c                 ó~   — | j                  |«      }i }| j                  D ]  } | j                  |   |«      ||<   Œ |S r   )r  r*  r,  )r   r‚   r    rp   s       r   r   zLxmertVisualObjHead.forward€  sL   € ØŸ™ }Ó5ˆØˆØ×%Ñ%ò 	@ˆCØ0˜$×+Ñ+¨CÑ0°Ó?ˆF�3ŠKð	@àˆr   r   r#   s   @r   r  r  i  s   ø„ ô
ö,r   r  c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚLxmertPreTrainingHeadsc                 óŒ   •— t         ‰| �  «        t        |«      | _        t	        j
                  |j                  d«      | _        y ré   )r   r   r  Úpredictionsr   rn   rF   Úseq_relationshiprP   s     €r   r   zLxmertPreTrainingHeads.__init__‰  s4   ø€ Ü‰ÑÔÜ1°&Ó9ˆÔÜ "§	¡	¨&×*<Ñ*<¸aÓ @ˆÕr   c                 óN   — | j                  |«      }| j                  |«      }||fS r   )r1  r2  )r   Úsequence_outputr)   Úprediction_scoresÚseq_relationship_scores        r   r   zLxmertPreTrainingHeads.forwardŽ  s0   € Ø ×,Ñ,¨_Ó=ÐØ!%×!6Ñ!6°}Ó!EÐØ Ð"8Ð8Ð8r   r   r#   s   @r   r/  r/  ˆ  s   ø„ ôAö
9r   r/  c                   óZ   ‡ — e Zd ZU eed<   dZdZ ej                  «       ˆ fd„«       Z	ˆ xZ
S )ÚLxmertPreTrainedModelrQ   Úlxmert)ÚimageÚtextc                 ó„   •— t         ‰| �  |«       t        |t        «      r t	        j
                  |j                  «       yy)zInitialize the weightsN)r   Ú_init_weightsÚ
isinstancer  ÚinitÚzeros_r  )r   Úmoduler   s     €r   r=  z#LxmertPreTrainedModel._init_weightsš  s2   ø€ ô 	‰Ñ˜fÔ%Ü�fÔ4Ô5Ü�K‰K˜Ÿ™Õ$ð 6r   )r   r    r!   r   r2   Úbase_model_prefixÚinput_modalitiesr0   Úno_gradr=  r"   r#   s   @r   r8  r8  ”  s/   ø… àÓØ ÐØ(Ðà€U‡]�]ƒ_ó%ó ô%r   r8  c                   óf  ‡ — e Zd Zˆ fd„Zd„ Zd„ Ze	 	 	 	 	 	 	 	 	 	 ddej                  dz  dej                  dz  dej                  dz  dej                  dz  d	ej                  dz  d
ej                  dz  dej                  dz  de
dz  de
dz  de
dz  deeej                     z  fd„«       Zˆ xZS )ÚLxmertModelc                 ó¤   •— t         ‰| �  |«       t        |«      | _        t	        |«      | _        t        |«      | _        | j                  «        y r   )	r   r   r>   rc   rí   Úencoderr  ÚpoolerÚ	post_initrP   s     €r   r   zLxmertModel.__init__¤  s>   ø€ Ü‰Ñ˜Ô Ü*¨6Ó2ˆŒÜ$ VÓ,ˆŒÜ" 6Ó*ˆŒà�‰Õr   c                 ó.   — | j                   j                  S r   ©rc   rG   ©r   s    r   Úget_input_embeddingsz LxmertModel.get_input_embeddings¬  s   € Ø�‰×.Ñ.Ð.r   c                 ó&   — || j                   _        y r   rL  )r   Únew_embeddingss     r   Úset_input_embeddingsz LxmertModel.set_input_embeddings¯  s   € Ø*8ˆ�‰Õ'r   Nr^   rÜ   rê   r„   rÎ   r_   r`   r…   Úoutput_hidden_statesÚreturn_dictÚreturnc           
      óH  — |�|n| j                   j                  }|	�|	n| j                   j                  }	|
�|
n| j                   j                  }
|�|�t	        d«      ‚|�#| j                  ||«       |j                  «       }n!|�|j                  «       dd }nt	        d«      ‚|€t	        d«      ‚|€t	        d«      ‚|�|j                  n|j                  }|€t        j                  ||¬«      }|€&t        j                  |t        j                  |¬«      }|j                  d	«      j                  d
«      }|j                  | j                  ¬«      }d|z
  t        j                  | j                  «      j                   z  }|�l|j                  d	«      j                  d
«      }|j                  | j                  ¬«      }d|z
  t        j                  | j                  «      j                   z  }nd}| j#                  |||«      }| j%                  ||||||¬«      }|dd
 \  }}|d   }|d   }d}|r|d	   }|d	   }|d
   }|||f}|	r||fnd}|d   }|d   }| j'                  |«      }|
s|||f|z   |z   S t)        ||||	r|nd|	r|nd|rnd|rnd|r¬«      S d¬«      S )aw  
        visual_feats (`torch.FloatTensor` of shape `(batch_size, num_visual_features, visual_feat_dim)`):
            This input represents visual features. They ROI pooled object features from bounding boxes using a
            faster-RCNN model)

            These are currently not provided by the transformers library.
        visual_pos (`torch.FloatTensor` of shape `(batch_size, num_visual_features, visual_pos_dim)`):
            This input represents spatial features corresponding to their relative (via index) visual features. The
            pre-trained LXMERT model expects these spatial features to be normalized bounding boxes on a scale of 0 to
            1.

            These are currently not provided by the transformers library.
        visual_attention_mask (`torch.FloatTensor` 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)
        NzDYou cannot specify both input_ids and inputs_embeds at the same timerS   z5You have to specify either input_ids or inputs_embedsz`visual_feats` cannot be `None`z`visual_pos` cannot be `None`©rV   rT   r   ru   )rU   g      ð?)rÜ   rê   rÎ   r…   r   r4   )r)   r'   r(   r*   r+   r,   r-   r.   )rQ   r…   rR  rS  rj   Ú%warn_if_padding_and_no_attention_maskrW   rV   r0   Úonesr\   rY   rZ   ÚtorU   ÚfinfoÚminrc   rH  rI  r&   )r   r^   rÜ   rê   r„   rÎ   r_   r`   r…   rR  rS  Úkwargsra   rV   Úextended_attention_maskÚextended_visual_attention_maskÚembedding_outputÚencoder_outputsrþ   rÿ   r+   r*   Úall_attentionsr,   r-   r.   r‚   rØ   rÇ   r)   s                                 r   r   zLxmertModel.forward²  s2  € ðF 2CÐ1NÑ-ÐTX×T_ÑT_×TqÑTqÐà$8Ð$DÑ È$Ï+É+×JjÑJjð 	ð &1Ð%<‘kÀ$Ç+Á+×BYÑBYˆàÐ  ]Ð%>ÜÐcÓdÐdØÐ"Ø×6Ñ6°yÀ.ÔQØ#Ÿ.™.Ó*‰KØÐ&Ø'×,Ñ,Ó.¨s°Ð3‰KäÐTÓUÐUàÐÜÐ>Ó?Ð?ØÐÜÐ<Ó=Ð=à%.Ð%:�×!Ò!À×@TÑ@TˆàÐ!Ü"ŸZ™Z¨¸FÔCˆNØÐ!Ü"Ÿ[™[¨¼E¿J¹JÈvÔVˆNð #1×":Ñ":¸1Ó"=×"GÑ"GÈÓ"JÐð #:×"<Ñ"<À4Ç:Á:Ð"<Ó"NÐØ#&Ð)@Ñ#@ÄEÇKÁKÐPT×PZÑPZÓD[×D_ÑD_Ñ"_Ðð !Ð,Ø-B×-LÑ-LÈQÓ-O×-YÑ-YÐZ[Ó-\Ð*Ø-K×-NÑ-NÐUY×U_ÑU_Ð-NÓ-`Ð*Ø.1Ð4RÑ.RÔV[×VaÑVaÐbf×blÑblÓVm×VqÑVqÑ-qÑ*à-1Ð*ð  Ÿ?™?¨9°nÀmÓTÐð Ÿ,™,ØØ#Ø%Ø!Ø"@Ø/ð 'ó 
ˆð 8GÀrÈÐ7JÑ4ÐÐ 4Ø5°aÑ8ÐØ!5°aÑ!8ÐàˆÙØ"6°qÑ"9ÐØ 6°qÑ 9ÐØ'6°qÑ'9Ð$à#Ø!Ø(ðˆNñ K_Ð/Ð1EÑFÐdfˆà,¨RÑ0ˆØ,¨RÑ0ˆØŸ™ KÓ0ˆáØ °Ð>ÀÑNÐQ_Ñ_Ð_ä Ø'Ø'Ø'Ù=QÑ#9ÐW[Ù9MÑ!5ÐSWÙ7HÑ 3ÈdÙ3DÑ/È$ÙARÐ%=ô	
ð 		
ð Y]ô	
ð 		
r   )
NNNNNNNNNN)r   r    r!   r   rN  rQ  r   r0   Ú
LongTensorr1   Úboolr&   r3   r   r"   r#   s   @r   rF  rF  ¢  s(  ø„ ôò/ò9ð ð .2Ø15Ø/3Ø37Ø:>Ø26Ø26Ø)-Ø,0Ø#'ñC
à×#Ñ# dÑ*ðC
ð ×'Ñ'¨$Ñ.ðC
ð ×%Ñ%¨Ñ,ð	C
ð
 ×)Ñ)¨DÑ0ðC
ð  %×0Ñ0°4Ñ7ðC
ð ×(Ñ(¨4Ñ/ðC
ð ×(Ñ(¨4Ñ/ðC
ð   $™;ðC
ð # T™kðC
ð ˜D‘[ðC
ð 
˜U 5×#4Ñ#4Ñ5Ñ	5òC
ó ôC
r   rF  c            "       óˆ  ‡ — e Zd ZddiZˆ fd„Z	 ddededz  dedej                  fˆ fd	„Z	defd
„Z
d„ Zd„ Zdej                  fd„Zd„ Zd„ Ze	 	 	 	 	 	 	 	 	 	 	 	 	 	 d dej&                  dz  dej(                  dz  dej(                  dz  dej(                  dz  dej(                  dz  dej&                  dz  dej(                  dz  dej&                  dz  deeeej(                  ej(                  f   f   dz  dej&                  dz  dej0                  dz  dedz  dedz  dedz  deeej(                     z  fd„«       Zˆ xZS )!ÚLxmertForPreTrainingzcls.predictions.decoder.weightz(lxmert.embeddings.word_embeddings.weightc                 ó  •— t         ‰| �  |«       || _        |j                  | _        |j                  | _        |j
                  | _        |j                  | _        |j                  | _        |j                  | _        t        |«      | _
        t        |«      | _        | j                  rt        |«      | _        | j                  rt        || j                  «      | _        | j#                  «        t%        d¬«      t'        d¬«      t'        «       dœ| _        i }|j*                  rd|j,                  ddœ|d<   |j.                  rd|j0                  ddœ|d<   |j2                  rd	|j4                  f|j4                  d
dœ|d<   || _        y )NÚnone)Ú	reduction)Úl2Ú	visual_ceÚcer   rj  )rx   r!  r7   r"  r#  rS   ri  r$  )r   r   rQ   Únum_qa_labelsÚvisual_loss_normalizerÚtask_mask_lmÚtask_obj_predictÚtask_matchedÚtask_qarF  r9  r/  Úclsr  Úobj_predict_headr  Úanswer_headrJ  r   r   Ú	loss_fctsr%  r&  r'  r(  r)  rà   r*  )r   rQ   r*  r   s      €r   r   zLxmertForPreTraining.__init__@  sq  ø€ Ü‰Ñ˜Ô àˆŒØ#×1Ñ1ˆÔØ&,×&CÑ&CˆÔ#ð #×/Ñ/ˆÔØ &× 7Ñ 7ˆÔØ"×/Ñ/ˆÔØ—~‘~ˆŒô " &Ó)ˆŒô *¨&Ó1ˆŒØ× Ò Ü$7¸Ó$?ˆDÔ!Ø�<Š<Ü5°f¸d×>PÑ>PÓQˆDÔð 	�‰Ôô ¨Ô0Ü)°FÔ;Ü"Ó$ñ
ˆŒð ˆØ×!Ò!àØ×/Ñ/Ø#ñ$ˆM˜%Ñ ð
 ×"Ò"àØ×-Ñ-Ø#ñ%ˆM˜&Ñ!ð
 ×"Ò"à˜f×4Ñ4Ð5Ø×-Ñ-Øñ%ˆM˜&Ñ!ð
 +ˆÕr   NÚnew_num_tokensÚpad_to_multiple_ofÚmean_resizingrT  c                 ó¼   •— t         ‰| �  |||«      }| j                  | j                  j                  j
                  |«      | j                  j                  _        |S r   )r   Úresize_token_embeddingsÚ_resize_biasrr  r1  r  )r   rv  rw  rx  rP  r   s        €r   rz  z,LxmertForPreTraining.resize_token_embeddingsw  sP   ø€ ô ™Ñ8¸ÐI[Ð]jÓkˆØ$(×$5Ñ$5°d·h±h×6JÑ6J×6OÑ6OÐQ_Ó$`ˆ�‰×ÑÔ!ØÐr   c                 óÚ   — |j                   d   }||k  r|d | }n;t        j                  ||z
  |j                  ¬«      }t        j                  ||g«      }t        j                  |«      }|S )Nr   rV  )rx   r0   r\   rV   Úcatr   r  )r   r  rv  Úold_num_tokensÚnew_biasÚ
extra_biass         r   r{  z!LxmertForPreTraining._resize_bias  sb   € ØŸ™ A™ˆØ˜^Ò+Ø˜O˜^Ð,‰HäŸ™ ^°nÑ%DÈTÏ[É[ÔYˆJÜ—y‘y $¨
Ð!3Ó4ˆHÜ—<‘< Ó)ˆØˆr   c                 ó‚   — | j                  «       }|�|€y| j                  |«      }|| j                  _        || _        |S ©aç  
        Build a resized question answering linear layer Module from a provided new linear layer. Increasing the size
        will add newly initialized weights. Reducing the size will remove weights from the end

        Args:
            num_labels (`int`, *optional*):
                New number of labels in the linear layer weight matrix. Increasing the size will add newly initialized
                weights at the end. Reducing the size will remove weights from the end. If not provided or `None`, just
                returns a pointer to the qa labels ``torch.nn.Linear``` module of the model without doing anything.

        Return:
            `torch.nn.Linear`: Pointer to the resized Linear layer or the old Linear layer
        N©Úget_qa_logit_layerÚ_resize_qa_labelsrQ   rl  ©r   r  Úcur_qa_logit_layerÚnew_qa_logit_layers       r   Úresize_num_qa_labelsz)LxmertForPreTraining.resize_num_qa_labels‰  óM   € ð "×4Ñ4Ó6ÐØÐÐ!3Ð!;ØØ!×3Ñ3°JÓ?ÐØ$.ˆ�‰Ô!Ø'ˆÔà!Ð!r   c                 óˆ   — | j                  «       }| j                  ||«      }| j                  |«       | j                  «       S r   ©r„  Ú_get_resized_qa_labelsÚ_set_qa_logit_layerr†  s       r   r…  z&LxmertForPreTraining._resize_qa_labels¡  óC   € Ø!×4Ñ4Ó6ÐØ!×8Ñ8Ð9KÈZÓXÐØ× Ñ Ð!3Ô4Ø×&Ñ&Ó(Ð(r   c                 óN   — t        | d«      r| j                  j                  d   S y)a  
        Returns the linear layer that produces question answering logits.

        Returns:
            `nn.Module`: A torch module mapping the question answering prediction hidden states or `None` if LXMERT
            does not have a visual answering head.
        rt  rS   N©Úhasattrrt  r  rM  s    r   r„  z'LxmertForPreTraining.get_qa_logit_layer§  s*   € ô �4˜Ô'Ø×#Ñ#×,Ñ,¨RÑ0Ð0ð (r   c                 ó6   — || j                   j                  d<   y ©NrS   ©rt  r  ©r   Úqa_logit_layers     r   rŽ  z(LxmertForPreTraining._set_qa_logit_layer²  ó   € Ø(6ˆ×Ñ×!Ñ! "Ò%r   c                 óD  — |€|S |j                   j                  «       \  }}||k(  r|S t        |dd «      �t        j                  ||«      }nt        j                  ||d¬«      }|j                  |j                   j                  «       | j                  |«       t        ||«      }|j                   j                  d |…d d …f   |j                   j                  d |…d d …f<   t        |dd «      �0|j                  j                  d | |j                  j                  d | |S ©Nr  Fr  ©ÚweightrW   Úgetattrr   rn   rY  rV   r=  r[  Údatar  ©r   r‡  r  Úcur_qa_labelsÚ
hidden_dimrˆ  Únum_labels_to_copys          r   r�  z+LxmertForPreTraining._get_resized_qa_labelsµ  ó-  € ØÐØ%Ð%à$6×$=Ñ$=×$BÑ$BÓ$DÑ!ˆ�zØ˜JÒ&Ø%Ð%ô Ð% v¨tÓ4Ð@Ü!#§¡¨:°zÓ!BÑä!#§¡¨:°zÈÔ!NÐà×ÑÐ0×7Ñ7×>Ñ>Ô?ð 	×ÑÐ-Ô.ô ! °
Ó;ÐØAS×AZÑAZ×A_ÑA_Ð`sÐasÐ`sÒuvÐ`vÑAwÐ×!Ñ!×&Ñ&Ð':Ð(:Ð':ºAÐ'=Ñ>ÜÐ% v¨tÓ4Ð@Ø@R×@WÑ@W×@\Ñ@\Ð]pÐ^pÐ@qÐ×#Ñ#×(Ñ(Ð)<Ð*<Ð=à!Ð!r   r^   rÜ   rê   r„   rÎ   r_   r`   ÚlabelsÚ
obj_labelsÚmatched_labelÚansr…   rR  rS  c                 óH  — |�|n| j                   j                  }|�|j                  n|j                  }| j                  ||||||||||¬«
      }|d   |d   |d   }}}| j	                  ||«      \  }}| j
                  r| j                  |«      }n|d   d   }|€|
€|	€|€dnt        j                  d|¬«      }|�Z| j                  rN | j                  d   |j                  d	| j                   j                  «      |j                  d	«      «      }||z  }|
�F| j                  r: | j                  d   |j                  d	d«      |
j                  d	«      «      }||z  }|	��| j                  �rt        j                  d|j                  ¬«      }| j                  |«      }| j                   j#                  «       D ]²  \  }}|	|   \  }} |d
   }!|d   }"|d   }#| j$                  }$| j                  |"   }%||   }& |%|&j                  d	|!«      |j                  |#«      «      }'|'j'                  «       dkD  r|'j)                  d«      }'|'| j                  d	«      z  j)                  «       |$z  }'||'z  }Œ´ ||z  }|�P| j
                  rD | j                  d   |j                  d	| j*                  «      |j                  d	«      «      }(||(z  }|s|||f|dd z   })|�|f|)z   S |)S t-        |||||j.                  |j0                  |j2                  |j4                  |j6                  ¬«	      S )a²	  
        visual_feats (`torch.FloatTensor` of shape `(batch_size, num_visual_features, visual_feat_dim)`):
            This input represents visual features. They ROI pooled object features from bounding boxes using a
            faster-RCNN model)

            These are currently not provided by the transformers library.
        visual_pos (`torch.FloatTensor` of shape `(batch_size, num_visual_features, visual_pos_dim)`):
            This input represents spatial features corresponding to their relative (via index) visual features. The
            pre-trained LXMERT model expects these spatial features to be normalized bounding boxes on a scale of 0 to
            1.

            These are currently not provided by the transformers library.
        visual_attention_mask (`torch.FloatTensor` 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)
        labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
            Labels for computing the masked language modeling loss. Indices should be in `[-100, 0, ...,
            config.vocab_size]` (see `input_ids` docstring) Tokens with indices set to `-100` are ignored (masked), the
            loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`
        obj_labels (`dict[Str: tuple[Torch.FloatTensor, Torch.FloatTensor]]`, *optional*):
            each key is named after each one of the visual losses and each element of the tuple is of the shape
            `(batch_size, num_features)` and `(batch_size, num_features, visual_feature_dim)` for each the label id and
            the label score respectively
        matched_label (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
            Labels for computing the whether or not the text input matches the image (classification) loss. Input
            should be a sequence pair (see `input_ids` docstring) Indices should be in `[0, 1]`:

            - 0 indicates that the sentence does not match the image,
            - 1 indicates that the sentence does match the image.
        ans (`Torch.Tensor` of shape `(batch_size)`, *optional*):
            a one hot representation hof the correct answer *optional*
        N©
r^   rÜ   rê   r_   r„   rÎ   r`   rR  r…   rS  r   r   ru   g        rV  rk  rS   r!  r7   rx   r   )	r7   r;   r<   r8   r*   r+   r,   r-   r.   )rQ   rS  rV   r9  rr  rq  rt  r0   Útensorrn  ru  ry   rE   rp  ro  rs  r*  Úitemsrm  rw   Úmeanrl  r:   r*   r+   r,   r-   r.   )*r   r^   rÜ   rê   r„   rÎ   r_   r`   r¤  r¥  r¦  r§  r…   rR  rS  r\  rV   Úlxmert_outputrÇ   rØ   r)   Úlang_prediction_scoresr<   Úanswer_scoreÚ
total_lossÚmasked_lm_lossÚmatched_lossÚtotal_visual_lossÚvisual_prediction_scores_dictrp   Úkey_infoÚlabelÚ	mask_confÚ
output_dimÚloss_fct_nameÚlabel_shaperœ  Úvisual_loss_fctÚvisual_prediction_scoresÚvisual_lossÚanswer_lossr    s*                                             r   r   zLxmertForPreTraining.forwardÐ  sŽ  € ðp &1Ð%<‘kÀ$Ç+Á+×BYÑBYˆà%.Ð%:�×!Ò!À×@TÑ@TˆØŸ™ØØ%Ø!Ø)Ø)Ø"7Ø'Ø!5Ø/Ø#ð $ó 
ˆð ˜!ÑØ˜!ÑØ˜!Ñð %2�]ˆð
 <@¿8¹8ÀKÐQ^Ó;_Ñ8ÐÐ 8Ø�<Š<Ø×+Ñ+¨MÓ:‰Là(¨Ñ+¨AÑ.ˆLð � =Ð#8¸ZÐ=OÐTWÐT_ñ ä—‘˜c¨&Ô1ð 	ð
 Ð $×"3Ò"3Ø1˜TŸ^™^¨DÑ1Ø&×+Ñ+¨B°·±×0FÑ0FÓGØ—‘˜B“óˆNð ˜.Ñ(ˆJØÐ$¨×):Ò):Ø/˜4Ÿ>™>¨$Ñ/Ð0H×0MÑ0MÈbÐRSÓ0TÐVc×VhÑVhÐikÓVlÓmˆLØ˜,Ñ&ˆJØÑ! d×&;Ó&;Ü %§¡¨S¸×9IÑ9IÔ JÐØ,0×,AÑ,AÀ-Ó,PÐ)Ø!%×!3Ñ!3×!9Ñ!9Ó!;ò 1‘��XØ#-¨c¡?Ñ ��yØ% e™_�
Ø (¨Ñ 0�Ø& wÑ/�Ø×4Ñ4�Ø"&§.¡.°Ñ"?�Ø+HÈÑ+MÐ(Ù-Ø,×1Ñ1°"°jÓAØ—J‘J˜{Ó+ó�ð —?‘?Ó$ qÒ(Ø"-×"2Ñ"2°1Ó"5�KØ*¨Y¯^©^¸BÓ-?Ñ?×EÑEÓGÈ&ÑP�Ø! [Ñ0Ñ!ð1ð  Ð+Ñ+ˆJØˆ?˜tŸ|š|Ø.˜$Ÿ.™.¨Ñ.¨|×/@Ñ/@ÀÀT×EWÑEWÓ/XÐZ]×ZbÑZbÐceÓZfÓgˆKØ˜+Ñ%ˆJáà&Ø(Øðð ˜a˜bÐ!ñ	"ˆFð
 0:Ð/E�Z�M FÑ*ÐQÈ6ÐQä)ØØ4Ø%=Ø%1Ø#0×#GÑ#GØ!.×!CÑ!CØ -× AÑ AØ+×=Ñ=Ø%2×%KÑ%Kô

ð 
	
r   )NT)NNNNNNNNNNNNNN)r   r    r!   Ú_tied_weights_keysr   rk   rc  r   rD   rz  r{  r‰  r…  ÚModuler„  rŽ  r�  r   r0   rb  r1   ÚdictÚstrr3   ÚTensorr:   r   r"   r#   s   @r   re  re  9  s  ø„ ð 	)Ð*TðÐô5+ðp aeñØ!ðØ7:¸T±zðØY]ðà	�‰õð°ó ò"ò0)ð	1 B§I¡Ió 	1ò7ò"ð6 ð .2Ø15Ø/3Ø37Ø:>Ø26Ø26Ø*.ØTXØ15Ø#'Ø)-Ø,0Ø#'ñJ
à×#Ñ# dÑ*ðJ
ð ×'Ñ'¨$Ñ.ðJ
ð ×%Ñ%¨Ñ,ð	J
ð
 ×)Ñ)¨DÑ0ðJ
ð  %×0Ñ0°4Ñ7ðJ
ð ×(Ñ(¨4Ñ/ðJ
ð ×(Ñ(¨4Ñ/ðJ
ð × Ñ  4Ñ'ðJ
ð ˜˜e E×$5Ñ$5°u×7HÑ7HÐ$HÑIÐIÑJÈTÑQðJ
ð ×'Ñ'¨$Ñ.ðJ
ð �\‰\˜DÑ ðJ
ð   $™;ðJ
ð # T™kðJ
ð ˜D‘[ðJ
ð" 
$ e¨E×,=Ñ,=Ñ&>Ñ	>ò#J
ó ôJ
r   re  zR
    Lxmert Model with a visual-answering head on top for downstream QA tasks
    c                   ó²  ‡ — e Zd Zˆ fd„Zd„ Zd„ Zdej                  fd„Zd„ Z	d„ Z
e	 	 	 	 	 	 	 	 	 	 	 dd	ej                  dz  d
ej                  dz  dej                  dz  dej                  dz  dej                  dz  dej                  dz  dej                  dz  dej                  dz  dedz  dedz  dedz  deeej                     z  fd„«       Zˆ xZS )ÚLxmertForQuestionAnsweringc                 ó
  •— t         ‰| �  |«       || _        |j                  | _        |j                  | _        t        |«      | _        t        || j                  «      | _        | j                  «        t        «       | _        y r   )r   r   rQ   rl  rm  rF  r9  r  rt  rJ  r   r7   rP   s     €r   r   z#LxmertForQuestionAnswering.__init__d  sn   ø€ Ü‰Ñ˜Ô àˆŒØ#×1Ñ1ˆÔØ&,×&CÑ&CˆÔ#ô " &Ó)ˆŒä1°&¸$×:LÑ:LÓMˆÔð 	�‰Ôô %Ó&ˆ�	r   c                 ó‚   — | j                  «       }|�|€y| j                  |«      }|| j                  _        || _        |S r‚  rƒ  r†  s       r   r‰  z/LxmertForQuestionAnswering.resize_num_qa_labelsw  rŠ  r   c                 óˆ   — | j                  «       }| j                  ||«      }| j                  |«       | j                  «       S r   rŒ  r†  s       r   r…  z,LxmertForQuestionAnswering._resize_qa_labels�  r�  r   rT  c                 óN   — t        | d«      r| j                  j                  d   S y)a  
        Returns the linear layer that produces question answering logits

        Returns:
            `nn.Module`: A torch module mapping the question answering prediction hidden states. `None`: A NoneType
            object if Lxmert does not have the visual answering head.
        rt  rS   Nr‘  rM  s    r   r„  z-LxmertForQuestionAnswering.get_qa_logit_layer•  s*   € ô �4˜Ô'Ø×#Ñ#×,Ñ,¨RÑ0Ð0ð (r   c                 ó6   — || j                   j                  d<   y r”  r•  r–  s     r   rŽ  z.LxmertForQuestionAnswering._set_qa_logit_layer¡  r˜  r   c                 óD  — |€|S |j                   j                  «       \  }}||k(  r|S t        |dd «      �t        j                  ||«      }nt        j                  ||d¬«      }|j                  |j                   j                  «       | j                  |«       t        ||«      }|j                   j                  d |…d d …f   |j                   j                  d |…d d …f<   t        |dd «      �0|j                  j                  d | |j                  j                  d | |S rš  r›  rŸ  s          r   r�  z1LxmertForQuestionAnswering._get_resized_qa_labels¤  r£  r   Nr^   rÜ   rê   r„   rÎ   r_   r`   r¤  r…   rR  rS  c                 óÈ  — |�|n| j                   j                  }| j                  ||||||||
|	|¬«
      }|d   }| j                  |«      }d}|�;| j	                  |j                  d| j                  «      |j                  d«      «      }|s|f|dd z   }|�|f|z   S |S t        |||j                  |j                  |j                  |j                  |j                  ¬«      S )a÷  
        visual_feats (`torch.FloatTensor` of shape `(batch_size, num_visual_features, visual_feat_dim)`):
            This input represents visual features. They ROI pooled object features from bounding boxes using a
            faster-RCNN model)

            These are currently not provided by the transformers library.
        visual_pos (`torch.FloatTensor` of shape `(batch_size, num_visual_features, visual_pos_dim)`):
            This input represents spatial features corresponding to their relative (via index) visual features. The
            pre-trained LXMERT model expects these spatial features to be normalized bounding boxes on a scale of 0 to
            1.

            These are currently not provided by the transformers library.
        visual_attention_mask (`torch.FloatTensor` 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)
        labels (`Torch.Tensor` of shape `(batch_size)`, *optional*):
            A one-hot representation of the correct answer
        Nr©  ru   rS   r   )r7   r8   r*   r+   r,   r-   r.   )rQ   rS  r9  rt  r7   ry   rl  r6   r*   r+   r,   r-   r.   )r   r^   rÜ   rê   r„   rÎ   r_   r`   r¤  r…   rR  rS  r\  r­  r)   r¯  r7   r    s                     r   r   z"LxmertForQuestionAnswering.forward¿  s  € ðL &1Ð%<‘kÀ$Ç+Á+×BYÑBYˆàŸ™ØØ%Ø!Ø)Ø)Ø"7Ø'Ø!5Ø/Ø#ð $ó 
ˆð & aÑ(ˆØ×'Ñ'¨Ó6ˆØˆØÐØ—9‘9˜\×.Ñ.¨r°4×3EÑ3EÓFÈÏÉÐTVËÓXˆDáØ"�_ }°Q°RÐ'8Ñ8ˆFØ'+Ð'7�D�7˜VÑ#ÐC¸VÐCä/ØØ%1Ø#0×#GÑ#GØ!.×!CÑ!CØ -× AÑ AØ+×=Ñ=Ø%2×%KÑ%Kô
ð 	
r   )NNNNNNNNNNN)r   r    r!   r   r‰  r…  r   rÀ  r„  rŽ  r�  r   r0   rb  r1   rÃ  rc  r6   r3   r   r"   r#   s   @r   rÅ  rÅ  ^  sY  ø„ ô'ò&"ò0)ð
1 B§I¡Ió 
1ò7ò"ð6 ð .2Ø15Ø/3Ø37Ø:>Ø26Ø26Ø&*Ø)-Ø,0Ø#'ñF
à×#Ñ# dÑ*ðF
ð ×'Ñ'¨$Ñ.ðF
ð ×%Ñ%¨Ñ,ð	F
ð
 ×)Ñ)¨DÑ0ðF
ð  %×0Ñ0°4Ñ7ðF
ð ×(Ñ(¨4Ñ/ðF
ð ×(Ñ(¨4Ñ/ðF
ð —‘˜tÑ#ðF
ð   $™;ðF
ð # T™kðF
ð ˜D‘[ðF
ð 
*¨E°%×2CÑ2CÑ,DÑ	DòF
ó ôF
r   rÅ  )rí   re  rÅ  rF  r8  rÞ   rÁ   )5r/   r|   Údataclassesr   r0   r   Útorch.nnr   r   Ú r   r?  Úactivationsr	   r
   Úmodeling_utilsr   Úutilsr   r   r   Úconfiguration_lxmertr   Ú
get_loggerr   ÚloggerrÀ  r   r&   r6   r:   r>   rf   r’   r�   r¨   r­   rµ   r¹   rÁ   rÞ   rí   r  r  r  r  r  r/  r8  rF  re  rÅ  Ú__all__r4   r   r   ú<module>r×     sŒ  ðñ ã Ý !ã Ý ß 3å &ß 'Ý -ß 9Ñ 9Ý .ð 
ˆ×	Ñ	˜HÓ	%€ôˆ2�9‰9ô ñ ðôð ô$E˜ó $Eó óð$EñN ðôð
 ô!E {ó !Eó óð!EñH ðôð
 ô(E ó (Eó óð(EôV#�r—y‘yô #ôL1�b—i‘iô 1ôh˜BŸI™Iô ô §	¡	ô ô˜rŸy™yô ô*	˜Ÿ™ô 	ô�2—9‘9ô ô�"—)‘)ô ô X
�2—9‘9ô X
ôv §¡ô ô6N
�B—I‘Iô N
ôb�2—9‘9ô ô B§I¡Iô ô
˜RŸY™Yô 
ô,˜RŸY™Yô ,ô˜"Ÿ)™)ô ô>	9˜RŸY™Yô 	9ð ô
%˜Oó 
%ó ð
%ð ôS
Ð'ó S
ó ðS
ðl ôa
Ð0ó a
ó ða
ñH	 ðôô
c
Ð!6ó c
óð
c
òL�r   