§
    ‚Štjìy ã                   ó  — d Z ddl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	m
Z
 ddlmZ ddlmZ dd	lmZ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 ddl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)dZ*dZ+ e#d¬¦  «        e G d„ de"¦  «        ¦   «         ¦   «         Z, G d„ dej-        ¦  «        Z. G d„ dej-        ¦  «        Z/ G d„ dej-        ¦  «        Z0 G d„ dej-        ¦  «        Z1 G d „ d!ej-        ¦  «        Z2 G d"„ d#ej-        ¦  «        Z3 G d$„ d%e¦  «        Z4 G d&„ d'ej-        ¦  «        Z5 G d(„ d)ej-        ¦  «        Z6 G d*„ d+ej-        ¦  «        Z7 G d,„ d-ej-        ¦  «        Z8 G d.„ d/ej-        ¦  «        Z9e# G d0„ d1e¦  «        ¦   «         Z:e# G d2„ d3e:¦  «        ¦   «         Z;e# G d4„ d5e:¦  «        ¦   «         Z< e#d6¬¦  «         G d7„ d8e:¦  «        ¦   «         Z= e#d9¬¦  «         G d:„ d;e:¦  «        ¦   «         Z>	  G d<„ d=e?ej@        ¦  «        ZA G d>„ d?¦  «        ZB G d@„ dAeB¦  «        ZCd^dC„ZDd_dE„ZEd`dG„ZFdH„ ZGdadJ„ZHdbdL„ZIdcdN„ZJdddP„ZKdQ„ ZLdR„ ZMdS„ ZNdT„ ZOdU„ ZPdV„ ZQdW„ ZRdX„ ZSdedZeTfd[„ZUd\„ ZVg d]¢ZWdS )fzPyTorch TAPAS model.é    N)Ú	dataclass)Únn)ÚBCEWithLogitsLossÚCrossEntropyLossÚMSELossé   )Úinitialization)ÚACT2FN)ÚCacheÚDynamicCacheÚEncoderDecoderCache)Úcreate_bidirectional_mask)ÚGradientCheckpointingLayer)ÚBaseModelOutputÚBaseModelOutputWithPoolingÚMaskedLMOutputÚSequenceClassifierOutput)ÚPreTrainedModel)Úapply_chunking_to_forward)ÚModelOutputÚauto_docstringÚloggingé   )ÚTapasConfigg»½×Ùß|Û=g     ˆÃÀz7
    Output type of [`TapasForQuestionAnswering`].
    )Úcustom_introc                   óÂ   — 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S )ÚTableQuestionAnsweringOutputaÖ  
    loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` (and possibly `answer`, `aggregation_labels`, `numeric_values` and `numeric_values_scale` are provided)):
        Total loss as the sum of the hierarchical cell selection log-likelihood loss and (optionally) the
        semi-supervised regression loss and (optionally) supervised loss for aggregations.
    logits (`torch.FloatTensor` of shape `(batch_size, sequence_length)`):
        Prediction scores of the cell selection head, for every token.
    logits_aggregation (`torch.FloatTensor`, *optional*, of shape `(batch_size, num_aggregation_labels)`):
        Prediction scores of the aggregation head, for every aggregation operator.
    NÚlossÚlogitsÚlogits_aggregationÚhidden_statesÚ
attentions)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚtorchÚFloatTensorÚ__annotations__r   r    r!   Útupler"   © ó    úf/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/models/tapas/modeling_tapas.pyr   r   +   s¡   € € € € € € ðð ð &*€Dˆ%Ô
˜dÑ
"Ð)Ð)Ñ)Ø'+€FˆEÔ Ñ$Ð+Ð+Ñ+Ø37Ð˜Ô)¨DÑ0Ð7Ð7Ñ7Ø59€M�5˜Ô*Ô+¨dÑ2Ð9Ð9Ñ9Ø26€J��eÔ'Ô(¨4Ñ/Ð6Ð6Ñ6Ð6Ð6r,   r   c                   ó*   ‡ — e Zd ZdZˆ fd„Zdd„Zˆ xZS )ÚTapasEmbeddingsz¿
    Construct the embeddings from word, position and token_type embeddings. Same as BertEmbeddings but with a number of
    additional token type embeddings to encode tabular structure.
    c           	      ó<  •— t          ¦   «                              ¦   «          t          j        |j        |j        |j        ¬¦  «        | _        t          j        |j        |j        ¦  «        | _	        t          |j        ¦  «        D ]3\  }}d|› �}t          | |t          j        ||j        ¦  «        ¦  «         Œ4t          |j        ¦  «        | _        t          j        |j        |j        ¬¦  «        | _        t          j        |j        ¦  «        | _        || _        d S )N)Úpadding_idxÚtoken_type_embeddings_©Úeps)ÚsuperÚ__init__r   Ú	EmbeddingÚ
vocab_sizeÚhidden_sizeÚpad_token_idÚword_embeddingsÚmax_position_embeddingsÚposition_embeddingsÚ	enumerateÚtype_vocab_sizesÚsetattrÚlenÚnumber_of_token_type_embeddingsÚ	LayerNormÚlayer_norm_epsÚDropoutÚhidden_dropout_probÚdropoutÚconfig)ÚselfrH   Úir?   ÚnameÚ	__class__s        €r-   r6   zTapasEmbeddings.__init__I   sû   ø€ Ý‰Œ×ÒÑÔÐõ  "œ|¨FÔ,=¸vÔ?QÐ_eÔ_rÐsÑsÔsˆÔå#%¤<°Ô0NÐPVÔPbÑ#cÔ#cˆÔ å#,¨VÔ-DÑ#EÔ#Eð 	Tð 	TÑˆAÐØ/¨AÐ/Ð/ˆDÝ�D˜$¥¤Ð-=¸vÔ?QÑ RÔ RÑSÔSÐSÐSå/2°6Ô3JÑ/KÔ/KˆÔ,åœ fÔ&8¸fÔ>SÐTÑTÔTˆŒÝ”z &Ô"<Ñ=Ô=ˆŒàˆŒˆˆr,   Nc                 óæ  — |�|                      ¦   «         }n|                      ¦   «         d d…         }|d         }|�|j        n|j        }|�€Wt          j        |t          j        |¬¦  «        }|                     d¦  «                             |¦  «        }| j        j        �rt          |d d …d d …df         | j        j
        d         d¬¦  «        }t          |d d …d d …df         | j        j
        d         d¬¦  «        }	t          ||	¦  «        }
t          ||
¦  «        d         }t          ||
¦  «        }t          j        |t          j        |¬¦  «                             d¦  «        }t          j        t          j        | j        j        dz
  |¬¦  «        ||z
  ¦  «        }|€)t          j        || j        z   t          j        |¬¦  «        }|€|                      |¦  «        }|                      |¦  «        }||z   }t+          | j        ¦  «        D ]0}d|› �}| t-          | |¦  «        |d d …d d …|f         ¦  «        z  }Œ1|                      |¦  «        }|                      |¦  «        }|S )	Néÿÿÿÿr   ©ÚdtypeÚdevicer   )Ú
batch_dimsé   ©rQ   r2   )ÚsizerQ   r'   ÚarangeÚlongÚ	unsqueezeÚexpandrH   Úreset_position_index_per_cellÚIndexMapr?   ÚProductIndexMapÚ
reduce_minÚgatherÚminÚ	as_tensorr<   ÚzerosrB   r;   r=   ÚrangeÚgetattrrC   rG   )rI   Ú	input_idsÚtoken_type_idsÚposition_idsÚinputs_embedsÚinput_shapeÚ
seq_lengthrQ   Ú	col_indexÚ	row_indexÚ
full_indexÚfirst_position_per_segmentÚfirst_positionÚpositionr=   Ú
embeddingsrJ   rK   s                     r-   ÚforwardzTapasEmbeddings.forward\   s…  € ØÐ Ø#Ÿ.š.Ñ*Ô*ˆKˆKà'×,Ò,Ñ.Ô.¨s°¨sÔ3ˆKà  ”^ˆ
Ø%.Ð%:�Ô!Ð!ÀÔ@TˆàÑå œ<¨
½%¼*ÈVÐTÑTÔTˆLØ'×1Ò1°!Ñ4Ô4×;Ò;¸KÑHÔHˆLàŒ{Ô8ñ å$ ^°A°A°A°q°q°q¸!°GÔ%<¸d¼kÔ>ZÐ[\Ô>]ÐjkÐlÑlÔl�	å$ ^°A°A°A°q°q°q¸!°GÔ%<¸d¼kÔ>ZÐ[\Ô>]ÐjkÐlÑlÔl�	å,¨Y¸	ÑBÔB�
å-7¸ÀjÑ-QÔ-QÐRSÔ-TÐ*å!'Ð(BÀJÑ!OÔ!O�å œ<¨
½%¼*ÈVÐTÑTÔT×^Ò^Ð_`ÑaÔa�Ý$œyÝ”O D¤KÔ$GÈ!Ñ$KÐTZÐ[Ñ[Ô[Ð]eÐhvÑ]vñ ô  �ð Ð!Ý"œ[Ø˜tÔCÑCÍEÌJÐ_eðñ ô ˆNð Ð Ø ×0Ò0°Ñ;Ô;ˆMà"×6Ò6°|ÑDÔDÐà"Ð%8Ñ8ˆ
å�tÔ;Ñ<Ô<ð 	Gð 	GˆAØ/¨AÐ/Ð/ˆDØÐ-�' $¨Ñ-Ô-¨n¸Q¸Q¸QÀÀÀÀ1¸WÔ.EÑFÔFÑFˆJˆJà—^’^ JÑ/Ô/ˆ
Ø—\’\ *Ñ-Ô-ˆ
ØÐr,   )NNNN)r#   r$   r%   r&   r6   rq   Ú__classcell__©rL   s   @r-   r/   r/   C   sV   ø€ € € € € ðð ð
ð ð ð ð ð&1ð 1ð 1ð 1ð 1ð 1ð 1ð 1r,   r/   c                   ó0   ‡ — e Zd Zdˆ fd„	Z	 	 	 	 dd„Zˆ xZS )ÚTapasSelfAttentionNc                 óˆ  •— t          ¦   «                              ¦   «          |j        |j        z  dk    r/t	          |d¦  «        st          d|j        › d|j        › �¦  «        ‚|j        | _        t          |j        |j        z  ¦  «        | _        | j        | j        z  | _        t          j
        |j        | j        ¦  «        | _        t          j
        |j        | j        ¦  «        | _        t          j
        |j        | j        ¦  «        | _        t          j        |j        ¦  «        | _        |j        | _        || _        d S )Nr   Úembedding_sizezThe hidden size z4 is not a multiple of the number of attention heads )r5   r6   r9   Únum_attention_headsÚhasattrÚ
ValueErrorÚintÚattention_head_sizeÚall_head_sizer   ÚLinearÚqueryÚkeyÚvaluerE   Úattention_probs_dropout_probrG   Ú
is_decoderÚ	layer_idx©rI   rH   r„   rL   s      €r-   r6   zTapasSelfAttention.__init__‘   s%  ø€ Ý‰Œ×ÒÑÔÐØÔ Ô :Ñ:¸aÒ?Ð?ÍÐPVÐXhÑHiÔHiÐ?Ýð6 6Ô#5ð 6ð 6ØÔ3ð6ð 6ñô ð ð
 $*Ô#=ˆÔ Ý#& vÔ'9¸FÔ<VÑ'VÑ#WÔ#WˆÔ Ø!Ô5¸Ô8PÑPˆÔå”Y˜vÔ1°4Ô3EÑFÔFˆŒ
Ý”9˜VÔ/°Ô1CÑDÔDˆŒÝ”Y˜vÔ1°4Ô3EÑFÔFˆŒ
å”z &Ô"EÑFÔFˆŒØ Ô+ˆŒØ"ˆŒˆˆr,   Fc                 óX  — |j         d d…         }g |¢d‘| j        ‘R }|                      |¦  «                             |¦  «                             dd¦  «        }	d}
|d u}|�Ht          |t          ¦  «        r1|j                             | j	        ¦  «        }
|r|j
        }n
|j        }n|}|r|n|}|r3|�1|
r/|j        | j	                 j        }|j        | j	                 j        }n¿|                      |¦  «                             |¦  «                             dd¦  «        }|                      |¦  «                             |¦  «                             dd¦  «        }|�E|                     ||| j	        ¦  «        \  }}|r$t          |t          ¦  «        rd|j        | j	        <   t%          j        |	|                     dd¦  «        ¦  «        }|t)          j        | j        ¦  «        z  }|�||z   }t,          j                             |d¬¦  «        }|                      |¦  «        }t%          j        ||¦  «        }|                     dddd	¦  «                             ¦   «         }|                     ¦   «         d d…         | j        fz   } |j        |Ž }|r||fn|f}| j        r||fz   }|S )
NrN   r   rS   FTéþÿÿÿ©Údimr   r   )Úshaper|   r   ÚviewÚ	transposeÚ
isinstancer   Ú
is_updatedÚgetr„   Úcross_attention_cacheÚself_attention_cacheÚlayersÚkeysÚvaluesr€   r�   Úupdater'   ÚmatmulÚmathÚsqrtr   Ú
functionalÚsoftmaxrG   ÚpermuteÚ
contiguousrU   r}   rƒ   )rI   r!   Úattention_maskÚencoder_hidden_statesÚpast_key_valuesÚoutput_attentionsÚkwargsrh   Úhidden_shapeÚquery_layerrŽ   Úis_cross_attentionÚcurr_past_key_valuesÚcurrent_statesÚ	key_layerÚvalue_layerÚattention_scoresÚattention_probsÚcontext_layerÚnew_context_layer_shapeÚoutputss                        r-   rq   zTapasSelfAttention.forward¥   sß  € ð $Ô)¨#¨2¨#Ô.ˆØC˜ÐC bÐC¨$Ô*BÐCÐCˆØ—j’j Ñ/Ô/×4Ò4°\ÑBÔB×LÒLÈQÐPQÑRÔRˆàˆ
Ø2¸$Ð>ÐØÐ&Ý˜/Õ+>Ñ?Ô?ð 7Ø,Ô7×;Ò;¸D¼NÑKÔK�
Ø%ð Pà+:Ô+PÐ(Ð(à+:Ô+OÐ(Ð(à'6Ð$à2DÐWÐ.Ð.È-ˆØð 	F /Ð"=À*Ð"=à,Ô3°D´NÔCÔHˆIØ.Ô5°d´nÔEÔLˆKˆKàŸš Ñ0Ô0×5Ò5°lÑCÔC×MÒMÈaÐQRÑSÔSˆIØŸ*š* ^Ñ4Ô4×9Ò9¸,ÑGÔG×QÒQÐRSÐUVÑWÔWˆKàÐ*à)=×)DÒ)DÀYÐP[Ð]aÔ]kÑ)lÔ)lÑ&�	˜;à%ð F­*°_ÕFYÑ*ZÔ*Zð FØAE�OÔ.¨t¬~Ñ>õ !œ<¨°Y×5HÒ5HÈÈRÑ5PÔ5PÑQÔQÐØ+­d¬i¸Ô8PÑ.QÔ.QÑQÐØÐ%à/°.Ñ@Ðõ œ-×/Ò/Ð0@ÀbÐ/ÑIÔIˆð Ÿ,š, Ñ7Ô7ˆåœ _°kÑBÔBˆà%×-Ò-¨a°°A°qÑ9Ô9×DÒDÑFÔFˆØ"/×"4Ò"4Ñ"6Ô"6°s¸°sÔ";¸tÔ?QÐ>SÑ"SÐØ*˜Ô*Ð,CÐDˆà6GÐ]�= /Ð2Ð2ÈmÐM]ˆØŒ?ð 	3Ø Ð 2Ñ2ˆGØˆr,   ©N©NNNF©r#   r$   r%   r6   rq   rr   rs   s   @r-   ru   ru   �   sg   ø€ € € € € ð#ð #ð #ð #ð #ð #ð. Ø"ØØðAð Að Að Að Að Að Að Ar,   ru   c                   óP   ‡ — e Zd Zˆ fd„Zdej        dej        dej        fd„Zˆ xZS )ÚTapasSelfOutputc                 ó  •— t          ¦   «                              ¦   «          t          j        |j        |j        ¦  «        | _        t          j        |j        |j        ¬¦  «        | _        t          j        |j	        ¦  «        | _
        d S ©Nr3   )r5   r6   r   r~   r9   ÚdenserC   rD   rE   rF   rG   ©rI   rH   rL   s     €r-   r6   zTapasSelfOutput.__init__ë   sf   ø€ Ý‰Œ×ÒÑÔÐÝ”Y˜vÔ1°6Ô3EÑFÔFˆŒ
Ýœ fÔ&8¸fÔ>SÐTÑTÔTˆŒÝ”z &Ô"<Ñ=Ô=ˆŒˆˆr,   r!   Úinput_tensorÚreturnc                 óŠ   — |                       |¦  «        }|                      |¦  «        }|                      ||z   ¦  «        }|S r®   ©rµ   rG   rC   ©rI   r!   r·   s      r-   rq   zTapasSelfOutput.forwardñ   ó@   € ØŸ
š
 =Ñ1Ô1ˆØŸš ]Ñ3Ô3ˆØŸš }°|Ñ'CÑDÔDˆØÐr,   ©r#   r$   r%   r6   r'   ÚTensorrq   rr   rs   s   @r-   r²   r²   ê   ói   ø€ € € € € ð>ð >ð >ð >ð >ð U¤\ð ÀÄð ÐRWÔR^ð ð ð ð ð ð ð ð r,   r²   c                   ó–   ‡ — e Zd Zdˆ fd„	Z	 	 	 	 ddej        dej        dz  dej        dz  dedz  dedz  d	e	ej                 fd
„Z
ˆ xZS )ÚTapasAttentionNc                 óœ   •— t          ¦   «                              ¦   «          t          ||¬¦  «        | _        t	          |¦  «        | _        d S )N©r„   )r5   r6   ru   rI   r²   Úoutputr…   s      €r-   r6   zTapasAttention.__init__ù   s@   ø€ Ý‰Œ×ÒÑÔÐÝ& v¸ÐCÑCÔCˆŒ	Ý% fÑ-Ô-ˆŒˆˆr,   Fr!   r�   rž   rŸ   r    r¸   c                 óŽ   — |                       |||||¬¦  «        }|                      |d         |¦  «        }|f|dd …         z   }	|	S )N©r�   rž   rŸ   r    r   r   )rI   rÄ   )
rI   r!   r�   rž   rŸ   r    r¡   Úself_outputsÚattention_outputr­   s
             r-   rq   zTapasAttention.forwardÿ   s`   € ð —y’yØØ)Ø"7Ø+Ø/ð !ñ 
ô 
ˆð  Ÿ;š; |°A¤¸ÑFÔFÐØ#Ð%¨°Q°R°RÔ(8Ñ8ˆØˆr,   r®   r¯   )r#   r$   r%   r6   r'   r¾   r(   r   Úboolr*   rq   rr   rs   s   @r-   rÁ   rÁ   ø   s¿   ø€ € € € € ð.ð .ð .ð .ð .ð .ð 48Ø:>Ø(,Ø).ðð à”|ðð Ô)¨DÑ0ðð  %Ô0°4Ñ7ð	ð
  ™ðð   $™;ðð 
ˆuŒ|Ô	ðð ð ð ð ð ð ð r,   rÁ   c                   óB   ‡ — e Zd Zˆ fd„Zdej        dej        fd„Zˆ xZS )ÚTapasIntermediatec                 ó  •— t          ¦   «                              ¦   «          t          j        |j        |j        ¦  «        | _        t          |j        t          ¦  «        rt          |j                 | _        d S |j        | _        d S r®   )r5   r6   r   r~   r9   Úintermediate_sizerµ   r�   Ú
hidden_actÚstrr
   Úintermediate_act_fnr¶   s     €r-   r6   zTapasIntermediate.__init__  sn   ø€ Ý‰Œ×ÒÑÔÐÝ”Y˜vÔ1°6Ô3KÑLÔLˆŒ
Ý�fÔ'­Ñ-Ô-ð 	9Ý'-¨fÔ.?Ô'@ˆDÔ$Ð$Ð$à'-Ô'8ˆDÔ$Ð$Ð$r,   r!   r¸   c                 óZ   — |                       |¦  «        }|                      |¦  «        }|S r®   )rµ   rÐ   ©rI   r!   s     r-   rq   zTapasIntermediate.forward  s,   € ØŸ
š
 =Ñ1Ô1ˆØ×0Ò0°Ñ?Ô?ˆØÐr,   r½   rs   s   @r-   rË   rË     s^   ø€ € € € € ð9ð 9ð 9ð 9ð 9ð U¤\ð °e´lð ð ð ð ð ð ð ð r,   rË   c                   óP   ‡ — e Zd Zˆ fd„Zdej        dej        dej        fd„Zˆ xZS )ÚTapasOutputc                 ó  •— t          ¦   «                              ¦   «          t          j        |j        |j        ¦  «        | _        t          j        |j        |j        ¬¦  «        | _        t          j	        |j
        ¦  «        | _        d S r´   )r5   r6   r   r~   rÍ   r9   rµ   rC   rD   rE   rF   rG   r¶   s     €r-   r6   zTapasOutput.__init__&  sf   ø€ Ý‰Œ×ÒÑÔÐÝ”Y˜vÔ7¸Ô9KÑLÔLˆŒ
Ýœ fÔ&8¸fÔ>SÐTÑTÔTˆŒÝ”z &Ô"<Ñ=Ô=ˆŒˆˆr,   r!   r·   r¸   c                 óŠ   — |                       |¦  «        }|                      |¦  «        }|                      ||z   ¦  «        }|S r®   rº   r»   s      r-   rq   zTapasOutput.forward,  r¼   r,   r½   rs   s   @r-   rÔ   rÔ   %  r¿   r,   rÔ   c                   ó²   ‡ — e Zd Zdˆ fd„	Z	 	 	 	 	 ddej        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	ej                 fd„Z
d„ Zˆ xZS )Ú
TapasLayerNc                 ó†  •— t          ¦   «                              ¦   «          |j        | _        d| _        t	          ||¬¦  «        | _        |j        | _        |j        | _        | j        r/| j        st          | › d�¦  «        ‚t	          ||¬¦  «        | _	        t          |¦  «        | _        t          |¦  «        | _        d S )Nr   rÃ   z> should be used as a decoder model if cross attention is added)r5   r6   Úchunk_size_feed_forwardÚseq_len_dimrÁ   Ú	attentionrƒ   Úadd_cross_attentionrz   ÚcrossattentionrË   ÚintermediaterÔ   rÄ   r…   s      €r-   r6   zTapasLayer.__init__4  s»   ø€ Ý‰Œ×ÒÑÔÐØ'-Ô'EˆÔ$ØˆÔÝ'¨¸)ÐDÑDÔDˆŒØ Ô+ˆŒØ#)Ô#=ˆÔ ØÔ#ð 	NØ”?ð jÝ  DÐ!hÐ!hÐ!hÑiÔiÐiÝ"0°À9Ð"MÑ"MÔ"MˆDÔÝ-¨fÑ5Ô5ˆÔÝ! &Ñ)Ô)ˆŒˆˆr,   Fr!   r�   rž   Úencoder_attention_maskrŸ   r    r¸   c                 ó`  — |                       ||||¬¦  «        }|d         }	|dd …         }
| j        rT|�Rt          | d¦  «        st          d| › d�¦  «        ‚|                      |	||||¬¦  «        }|d         }	|
|dd …         z   }
t          | j        | j        | j        |	¦  «        }|f|
z   }
|
S )N)r�   r    rŸ   r   r   rÞ   z'If `encoder_hidden_states` are passed, z` has to be instantiated with cross-attention layers by setting `config.add_cross_attention=True`rÆ   )	rÜ   rƒ   ry   rz   rÞ   r   Úfeed_forward_chunkrÚ   rÛ   )rI   r!   r�   rž   rà   rŸ   r    r¡   Úself_attention_outputsrÈ   r­   Úcross_attention_outputsÚlayer_outputs                r-   rq   zTapasLayer.forwardC  s  € ð "&§¢ØØ)Ø/Ø+ð	 "0ñ "
ô "
Ðð 2°!Ô4ÐØ(¨¨¨Ô,ˆàŒ?ð 	<Ð4Ð@Ý˜4Ð!1Ñ2Ô2ð Ý ðD¸dð Dð Dð Dñô ð ð
 '+×&9Ò&9Ø Ø5Ø&;Ø /Ø"3ð ':ñ 'ô 'Ð#ð  7°qÔ9ÐØÐ 7¸¸¸Ô ;Ñ;ˆGå0ØÔ# TÔ%AÀ4ÔCSÐUeñ
ô 
ˆð  �/ GÑ+ˆàˆr,   c                 ó\   — |                       |¦  «        }|                      ||¦  «        }|S r®   )rß   rÄ   )rI   rÈ   Úintermediate_outputrå   s       r-   râ   zTapasLayer.feed_forward_chunko  s2   € Ø"×/Ò/Ð0@ÑAÔAÐØ—{’{Ð#6Ð8HÑIÔIˆØÐr,   r®   )NNNNF)r#   r$   r%   r6   r'   r¾   r(   r   rÉ   r*   rq   râ   rr   rs   s   @r-   rØ   rØ   3  sä   ø€ € € € € ð*ð *ð *ð *ð *ð *ð$ 48Ø:>Ø;?Ø(,Ø).ð)ð )à”|ð)ð Ô)¨DÑ0ð)ð  %Ô0°4Ñ7ð	)ð
 !&Ô 1°DÑ 8ð)ð  ™ð)ð   $™;ð)ð 
ˆuŒ|Ô	ð)ð )ð )ð )ðXð ð ð ð ð ð r,   rØ   c                   ó6   ‡ — e Zd Zˆ fd„Z	 	 	 	 	 	 	 	 dd„Zˆ xZS )ÚTapasEncoderc                 óÔ   •‡— t          ¦   «                              ¦   «          ‰| _        t          j        ˆfd„t          ‰j        ¦  «        D ¦   «         ¦  «        | _        d| _        d S )Nc                 ó2   •— g | ]}t          ‰|¬ ¦  «        ‘ŒS )rÃ   )rØ   )Ú.0rJ   rH   s     €r-   ú
<listcomp>z)TapasEncoder.__init__.<locals>.<listcomp>y  s&   ø€ Ð#mÐ#mÐ#mÈ¥J¨vÀÐ$CÑ$CÔ$CÐ#mÐ#mÐ#mr,   F)	r5   r6   rH   r   Ú
ModuleListrb   Únum_hidden_layersÚlayerÚgradient_checkpointingr¶   s    `€r-   r6   zTapasEncoder.__init__v  sa   øø€ Ý‰Œ×ÒÑÔÐØˆŒÝ”]Ð#mÐ#mÐ#mÐ#mÍUÐSYÔSkÑMlÔMlÐ#mÑ#mÔ#mÑnÔnˆŒ
Ø&+ˆÔ#Ð#Ð#r,   NFTc
           	      ó�  — |r8|€6t          t          | j        ¬¦  «        t          | j        ¬¦  «        ¦  «        }|rdnd }|rdnd }t          | j        ¦  «        D ]4\  }}|r||fz   } |||||||¬¦  «        }|d         }|r||d         fz   }Œ5|r||fz   }|	st          d„ |||fD ¦   «         ¦  «        S t          |||¬¦  «        S )N)rH   r+   )rà   rŸ   r    r   r   c              3   ó   K  — | ]}|®|V — Œ	d S r®   r+   )rì   Úvs     r-   ú	<genexpr>z'TapasEncoder.forward.<locals>.<genexpr>¢  s(   è è € ÐhÐh˜qÐZ[ÐZg˜ÐZgÐZgÐZgÐZgÐhÐhr,   )Úlast_hidden_stater!   r"   )r   r   rH   r>   rð   r*   r   )rI   r!   r�   rž   rà   rŸ   Ú	use_cacher    Úoutput_hidden_statesÚreturn_dictr¡   Úall_hidden_statesÚall_attentionsrJ   Úlayer_moduleÚlayer_outputss                   r-   rq   zTapasEncoder.forward|  sF  € ð ð 	v˜Ð0Ý1µ,ÀdÄkÐ2RÑ2RÔ2RÕT`ÐhlÔhsÐTtÑTtÔTtÑuÔuˆOà"6Ð@˜B˜B¸DÐØ0Ð:˜˜°dˆÝ(¨¬Ñ4Ô4ð 	Fð 	F‰OˆAˆ|Ø#ð IØ$5¸Ð8HÑ$HÐ!à(˜LØØØ%Ø'=Ø /Ø"3ðñ ô ˆMð *¨!Ô,ˆMØ ð FØ!/°=ÀÔ3CÐ2EÑ!E�øàð 	EØ 1°]Ð4DÑ DÐàð 	iÝÐhÐh ]Ð4EÀ~Ð$VÐhÑhÔhÑhÔhÐhÝØ+Ð;LÐYgð
ñ 
ô 
ð 	
r,   )NNNNNFFTr°   rs   s   @r-   ré   ré   u  sf   ø€ € € € € ð,ð ,ð ,ð ,ð ,ð Ø"Ø#ØØØØ"Øð)
ð )
ð )
ð )
ð )
ð )
ð )
ð )
r,   ré   c                   óB   ‡ — e Zd Zˆ fd„Zdej        dej        fd„Zˆ xZS )ÚTapasPoolerc                 óÀ   •— t          ¦   «                              ¦   «          t          j        |j        |j        ¦  «        | _        t          j        ¦   «         | _        d S r®   )r5   r6   r   r~   r9   rµ   ÚTanhÚ
activationr¶   s     €r-   r6   zTapasPooler.__init__ª  sC   ø€ Ý‰Œ×ÒÑÔÐÝ”Y˜vÔ1°6Ô3EÑFÔFˆŒ
Ýœ'™)œ)ˆŒˆˆr,   r!   r¸   c                 ór   — |d d …df         }|                       |¦  «        }|                      |¦  «        }|S ©Nr   )rµ   r  )rI   r!   Úfirst_token_tensorÚpooled_outputs       r-   rq   zTapasPooler.forward¯  s@   € ð +¨1¨1¨1¨a¨4Ô0ÐØŸ
š
Ð#5Ñ6Ô6ˆØŸš¨Ñ6Ô6ˆØÐr,   r½   rs   s   @r-   rÿ   rÿ   ©  s^   ø€ € € € € ð$ð $ð $ð $ð $ð
 U¤\ð °e´lð ð ð ð ð ð ð ð r,   rÿ   c                   óB   ‡ — e Zd Zˆ fd„Zdej        dej        fd„Zˆ xZS )ÚTapasPredictionHeadTransformc                 óV  •— t          ¦   «                              ¦   «          t          j        |j        |j        ¦  «        | _        t          |j        t          ¦  «        rt          |j                 | _
        n|j        | _
        t          j        |j        |j        ¬¦  «        | _        d S r´   )r5   r6   r   r~   r9   rµ   r�   rÎ   rÏ   r
   Útransform_act_fnrC   rD   r¶   s     €r-   r6   z%TapasPredictionHeadTransform.__init__º  s…   ø€ Ý‰Œ×ÒÑÔÐÝ”Y˜vÔ1°6Ô3EÑFÔFˆŒ
Ý�fÔ'­Ñ-Ô-ð 	6Ý$*¨6Ô+<Ô$=ˆDÔ!Ð!à$*Ô$5ˆDÔ!Ýœ fÔ&8¸fÔ>SÐTÑTÔTˆŒˆˆr,   r!   r¸   c                 ó„   — |                       |¦  «        }|                      |¦  «        }|                      |¦  «        }|S r®   )rµ   r
  rC   rÒ   s     r-   rq   z$TapasPredictionHeadTransform.forwardÃ  s=   € ØŸ
š
 =Ñ1Ô1ˆØ×-Ò-¨mÑ<Ô<ˆØŸš }Ñ5Ô5ˆØÐr,   r½   rs   s   @r-   r  r  ¹  sc   ø€ € € € € ðUð Uð Uð Uð Uð U¤\ð °e´lð ð ð ð ð ð ð ð r,   r  c                   ó$   ‡ — e Zd Zˆ fd„Zd„ Zˆ xZS )ÚTapasLMPredictionHeadc                 ó  •— t          ¦   «                              ¦   «          t          |¦  «        | _        t	          j        |j        |j        d¬¦  «        | _        t	          j	        t          j        |j        ¦  «        ¦  «        | _        d S )NT)Úbias)r5   r6   r  Ú	transformr   r~   r9   r8   ÚdecoderÚ	Parameterr'   ra   r  r¶   s     €r-   r6   zTapasLMPredictionHead.__init__Ì  sj   ø€ Ý‰Œ×ÒÑÔÐÝ5°fÑ=Ô=ˆŒõ ”y Ô!3°VÔ5FÈTÐRÑRÔRˆŒÝ”L¥¤¨VÔ->Ñ!?Ô!?Ñ@Ô@ˆŒ	ˆ	ˆ	r,   c                 óZ   — |                       |¦  «        }|                      |¦  «        }|S r®   )r  r  rÒ   s     r-   rq   zTapasLMPredictionHead.forwardÕ  s*   € ØŸš }Ñ5Ô5ˆØŸš ]Ñ3Ô3ˆØÐr,   r°   rs   s   @r-   r  r  Ë  sL   ø€ € € € € ðAð Að Að Að Aðð ð ð ð ð ð r,   r  c                   óB   ‡ — e Zd Zˆ fd„Zdej        dej        fd„Zˆ xZS )ÚTapasOnlyMLMHeadc                 óp   •— t          ¦   «                              ¦   «          t          |¦  «        | _        d S r®   )r5   r6   r  Úpredictionsr¶   s     €r-   r6   zTapasOnlyMLMHead.__init__Ý  s/   ø€ Ý‰Œ×ÒÑÔÐÝ0°Ñ8Ô8ˆÔÐÐr,   Úsequence_outputr¸   c                 ó0   — |                       |¦  «        }|S r®   )r  )rI   r  Úprediction_scoress      r-   rq   zTapasOnlyMLMHead.forwardá  s   € Ø ×,Ò,¨_Ñ=Ô=ÐØ Ð r,   r½   rs   s   @r-   r  r  Ü  s^   ø€ € € € € ð9ð 9ð 9ð 9ð 9ð! u¤|ð !¸¼ð !ð !ð !ð !ð !ð !ð !ð !r,   r  c                   ó\   ‡ — e Zd ZU eed<   dZdZ ej        ¦   «         ˆ fd„¦   «         Z	ˆ xZ
S )ÚTapasPreTrainedModelrH   ÚtapasTc                 óJ  •— t          ¦   «                              |¦  «         t          |t          ¦  «        rt	          j        |j        ¦  «         t          |t          ¦  «        r½|j        j	        r3t	          j        |j
        ¦  «         t	          j        |j        ¦  «         nJt	          j        |j
        |j        j        ¬¦  «         t	          j        |j        |j        j        ¬¦  «         t	          j        |j        ¦  «         t	          j        |j        ¦  «         dS dS )zInitialize the weights)ÚstdN)r5   Ú_init_weightsr�   r  ÚinitÚzeros_r  ÚTapasForQuestionAnsweringrH   Ú#init_cell_selection_weights_to_zeroÚoutput_weightsÚcolumn_output_weightsÚnormal_Úinitializer_rangeÚoutput_biasÚcolumn_output_bias)rI   ÚmodulerL   s     €r-   r   z"TapasPreTrainedModel._init_weightsì  sü   ø€ õ 	‰Œ×Ò˜fÑ%Ô%Ð%Ý�fÕ3Ñ4Ô4ð 	%ÝŒK˜œÑ$Ô$Ð$Ý�fÕ7Ñ8Ô8ð 	3ØŒ}Ô@ð `Ý”˜FÔ1Ñ2Ô2Ð2Ý”˜FÔ8Ñ9Ô9Ð9Ð9å”˜VÔ2¸¼Ô8WÐXÑXÔXÐXÝ”˜VÔ9¸v¼}Ô?^Ð_Ñ_Ô_Ð_ÝŒK˜Ô*Ñ+Ô+Ð+ÝŒK˜Ô1Ñ2Ô2Ð2Ð2Ð2ð	3ð 	3r,   )r#   r$   r%   r   r)   Úbase_model_prefixÚsupports_gradient_checkpointingr'   Úno_gradr   rr   rs   s   @r-   r  r  æ  sd   ø€ € € € € € àÐÐÑØÐØ&*Ð#à€U„]�_„_ð3ð 3ð 3ð 3ñ „_ð3ð 3ð 3ð 3ð 3r,   r  c                   ó  ‡ — e Zd ZdZdˆ 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z  fd„¦   «         Zˆ xZS )Ú
TapasModela  
    This class is a small change compared to [`BertModel`], taking into account the additional token type ids.

    The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
    cross-attention is added between the self-attention layers, following the architecture described in [Attention is
    all you need](https://huggingface.co/papers/1706.03762) by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
    Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.

    Tc                 ó   •— t          ¦   «                              |¦  «         || _        t          |¦  «        | _        t          |¦  «        | _        |rt          |¦  «        nd| _        |  	                    ¦   «          dS )zv
        add_pooling_layer (bool, *optional*, defaults to `True`):
            Whether to add a pooling layer
        N)
r5   r6   rH   r/   rp   ré   Úencoderrÿ   ÚpoolerÚ	post_init)rI   rH   Úadd_pooling_layerrL   s      €r-   r6   zTapasModel.__init__	  ss   ø€ õ
 	‰Œ×Ò˜Ñ Ô Ð ØˆŒå)¨&Ñ1Ô1ˆŒÝ# FÑ+Ô+ˆŒà->ÐH•k &Ñ)Ô)Ð)ÀDˆŒð 	�ŠÑÔÐÐÐr,   c                 ó   — | j         j        S r®   ©rp   r;   ©rI   s    r-   Úget_input_embeddingszTapasModel.get_input_embeddings  s   € ØŒÔ.Ð.r,   c                 ó   — || j         _        d S r®   r7  )rI   r�   s     r-   Úset_input_embeddingszTapasModel.set_input_embeddings  s   € Ø*/ˆŒÔ'Ð'Ð'r,   Nrd   r�   re   rf   rg   rž   rà   r    rø   rù   r¸   c           	      ó€  — |�|n| j         j        }|	�|	n| j         j        }	|
�|
n| j         j        }
|�|�t	          d¦  «        ‚|�+|                      ||¦  «         |                     ¦   «         }n.|�|                     ¦   «         dd…         }nt	          d¦  «        ‚|�|j        n|j        }|€t          j	        ||¬¦  «        }|€=t          j
        g |¢t          | j         j        ¦  «        ‘R t          j        |¬¦  «        }|                      ||||¬¦  «        }t          | j         ||¬¦  «        }|�t          | j         |||¬	¦  «        }|                      ||||||	|
¬
¦  «        }|d         }| j        �|                      |¦  «        nd}|
s||f|dd…         z   S t%          |||j        |j        ¬¦  «        S )aZ  
        token_type_ids (`torch.LongTensor` of shape `(batch_size, sequence_length, 7)`, *optional*):
            Token indices that encode tabular structure. Indices can be obtained using [`AutoTokenizer`]. See this
            class for more info.

            [What are token type IDs?](../glossary#token-type-ids)
        position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
            Indices of positions of each input sequence tokens in the position embeddings. If
            `reset_position_index_per_cell` of [`TapasConfig`] is set to `True`, relative position embeddings will be
            used. Selected in the range `[0, config.max_position_embeddings - 1]`.

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

        Examples:

        ```python
        >>> from transformers import AutoTokenizer, TapasModel
        >>> import pandas as pd

        >>> tokenizer = AutoTokenizer.from_pretrained("google/tapas-base")
        >>> model = TapasModel.from_pretrained("google/tapas-base")

        >>> data = {
        ...     "Actors": ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"],
        ...     "Age": ["56", "45", "59"],
        ...     "Number of movies": ["87", "53", "69"],
        ... }
        >>> table = pd.DataFrame.from_dict(data)
        >>> queries = ["How many movies has George Clooney played in?", "How old is Brad Pitt?"]

        >>> inputs = tokenizer(table=table, queries=queries, padding="max_length", return_tensors="pt")
        >>> outputs = model(**inputs)

        >>> last_hidden_states = outputs.last_hidden_state
        ```NzDYou cannot specify both input_ids and inputs_embeds at the same timerN   z5You have to specify either input_ids or inputs_embedsrT   rO   )rd   rf   re   rg   )rH   rg   r�   )rH   rg   r�   rž   )r�   rž   rà   r    rø   rù   r   r   )rö   Úpooler_outputr!   r"   )rH   r    rø   rù   rz   Ú%warn_if_padding_and_no_attention_maskrU   rQ   r'   Úonesra   rA   r?   rW   rp   r   r2  r3  r   r!   r"   )rI   rd   r�   re   rf   rg   rž   rà   r    rø   rù   r¡   rh   rQ   Úembedding_outputÚencoder_outputsr  r  s                     r-   rq   zTapasModel.forward  sG  € ðd 2CÐ1NÐ-Ð-ÐTXÔT_ÔTqÐà$8Ð$DÐ Ð È$Ì+ÔJjð 	ð &1Ð%<�k�kÀ$Ä+ÔBYˆàÐ  ]Ð%>ÝÐcÑdÔdÐdØÐ"Ø×6Ò6°yÀ.ÑQÔQÐQØ#Ÿ.š.Ñ*Ô*ˆKˆKØÐ&Ø'×,Ò,Ñ.Ô.¨s°¨sÔ3ˆKˆKåÐTÑUÔUÐUà%.Ð%:�Ô!Ð!ÀÔ@TˆàÐ!Ý"œZ¨¸FÐCÑCÔCˆNØÐ!Ý"œ[ØA�+ÐA�s 4¤;Ô#?Ñ@Ô@ÐAÐAÍÌÐ\bðñ ô ˆNð  Ÿ?š?Ø¨lÈ>Ðivð +ñ 
ô 
Ðõ 3Ø”;Ø*Ø)ð
ñ 
ô 
ˆð "Ð-Ý%>Ø”{Ø.Ø5Ø&;ð	&ñ &ô &Ð"ð Ÿ,š,ØØ)Ø"7Ø#9Ø/Ø!5Ø#ð 'ñ 
ô 
ˆð *¨!Ô,ˆØ8<¼Ð8O˜Ÿš OÑ4Ô4Ð4ÐUYˆàð 	JØ# ]Ð3°oÀaÀbÀbÔ6IÑIÐIå)Ø-Ø'Ø)Ô7Ø&Ô1ð	
ñ 
ô 
ð 	
r,   )T)
NNNNNNNNNN)r#   r$   r%   r&   r6   r9  r;  r   r'   Ú
LongTensorr(   rÉ   r*   r   rq   rr   rs   s   @r-   r0  r0  ý  st  ø€ € € € € ðð ðð ð ð ð ð ð /ð /ð /ð0ð 0ð 0ð ð .2Ø37Ø26Ø04Ø26Ø:>Ø;?Ø)-Ø,0Ø#'ðp
ð p
àÔ# dÑ*ðp
ð Ô)¨DÑ0ðp
ð Ô(¨4Ñ/ð	p
ð
 Ô&¨Ñ-ðp
ð Ô(¨4Ñ/ðp
ð  %Ô0°4Ñ7ðp
ð !&Ô 1°DÑ 8ðp
ð   $™;ðp
ð # T™kðp
ð ˜D‘[ðp
ð 
Ð+Ñ	+ðp
ð p
ð p
ñ „^ðp
ð p
ð p
ð p
ð p
r,   r0  c                   ó<  ‡ — e Zd ZU dddœZeed<   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j        d	z  ded	z  ded	z  ded	z  deez  fd„¦   «         Zˆ xZS )ÚTapasForMaskedLMzcls.predictions.biasz'tapas.embeddings.word_embeddings.weight)zcls.predictions.decoder.biaszcls.predictions.decoder.weightrH   r  c                 óÆ   •— t          ¦   «                              |¦  «         t          |d¬¦  «        | _        t	          |¦  «        | _        |                      ¦   «          d S )NF)r5  )r5   r6   r0  r  r  Úclsr4  r¶   s     €r-   r6   zTapasForMaskedLM.__init__œ  sV   ø€ Ý‰Œ×Ò˜Ñ Ô Ð å ¸%Ð@Ñ@Ô@ˆŒ
Ý# FÑ+Ô+ˆŒð 	�ŠÑÔÐÐÐr,   c                 ó$   — | j         j        j        S r®   )rF  r  r  r8  s    r-   Úget_output_embeddingsz&TapasForMaskedLM.get_output_embeddings¥  s   € ØŒxÔ#Ô+Ð+r,   c                 óT   — || j         j        _        |j        | j         j        _        d S r®   )rF  r  r  r  )rI   Únew_embeddingss     r-   Úset_output_embeddingsz&TapasForMaskedLM.set_output_embeddings¨  s%   € Ø'5ˆŒÔÔ$Ø$2Ô$7ˆŒÔÔ!Ð!Ð!r,   Nrd   r�   re   rf   rg   rž   rà   Úlabelsr    rø   rù   r¸   c                 ó¦  — |�|n| j         j        }|                      ||||||||	|
|¬¦
  «
        }|d         }|                      |¦  «        }d}|�Kt	          ¦   «         } ||                     d| j         j        ¦  «        |                     d¦  «        ¦  «        }|s|f|dd…         z   }|�|f|z   n|S t          |||j        |j	        ¬¦  «        S )aj  
        token_type_ids (`torch.LongTensor` of shape `(batch_size, sequence_length, 7)`, *optional*):
            Token indices that encode tabular structure. Indices can be obtained using [`AutoTokenizer`]. See this
            class for more info.

            [What are token type IDs?](../glossary#token-type-ids)
        position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
            Indices of positions of each input sequence tokens in the position embeddings. If
            `reset_position_index_per_cell` of [`TapasConfig`] is set to `True`, relative position embeddings will be
            used. Selected in the range `[0, config.max_position_embeddings - 1]`.

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

        Examples:

        ```python
        >>> from transformers import AutoTokenizer, TapasForMaskedLM
        >>> import pandas as pd

        >>> tokenizer = AutoTokenizer.from_pretrained("google/tapas-base")
        >>> model = TapasForMaskedLM.from_pretrained("google/tapas-base")

        >>> data = {
        ...     "Actors": ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"],
        ...     "Age": ["56", "45", "59"],
        ...     "Number of movies": ["87", "53", "69"],
        ... }
        >>> table = pd.DataFrame.from_dict(data)

        >>> inputs = tokenizer(
        ...     table=table, queries="How many [MASK] has George [MASK] played in?", return_tensors="pt"
        ... )
        >>> labels = tokenizer(
        ...     table=table, queries="How many movies has George Clooney played in?", return_tensors="pt"
        ... )["input_ids"]

        >>> outputs = model(**inputs, labels=labels)
        >>> logits = outputs.logits
        ```N)	r�   re   rf   rg   rž   rà   r    rø   rù   r   rN   rS   ©r   r   r!   r"   )
rH   rù   r  rF  r   r‹   r8   r   r!   r"   )rI   rd   r�   re   rf   rg   rž   rà   rL  r    rø   rù   r¡   r­   r  r  Úmasked_lm_lossÚloss_fctrÄ   s                      r-   rq   zTapasForMaskedLM.forward¬  s  € ðv &1Ð%<�k�kÀ$Ä+ÔBYˆà—*’*ØØ)Ø)Ø%Ø'Ø"7Ø#9Ø/Ø!5Ø#ð ñ 
ô 
ˆð " !œ*ˆØ ŸHšH _Ñ5Ô5ÐàˆØÐÝ'Ñ)Ô)ˆHØ%˜XÐ&7×&<Ò&<¸RÀÄÔAWÑ&XÔ&XÐZ`×ZeÒZeÐfhÑZiÔZiÑjÔjˆNàð 	ZØ'Ð)¨G°A°B°B¬KÑ7ˆFØ3AÐ3M�^Ð%¨Ñ.Ð.ÐSYÐYåØØ$Ø!Ô/ØÔ)ð	
ñ 
ô 
ð 	
r,   )NNNNNNNNNNN)r#   r$   r%   Ú_tied_weights_keysr   r)   r,  r6   rH  rK  r   r'   rB  r(   rÉ   r*   r   rq   rr   rs   s   @r-   rD  rD  “  s¥  ø€ € € € € € ð )?Ø*Sðð Ðð ÐÐÑØÐðð ð ð ð ð,ð ,ð ,ð8ð 8ð 8ð ð .2Ø37Ø26Ø04Ø26Ø:>Ø;?Ø*.Ø)-Ø,0Ø#'ðZ
ð Z
àÔ# dÑ*ðZ
ð Ô)¨DÑ0ðZ
ð Ô(¨4Ñ/ð	Z
ð
 Ô&¨Ñ-ðZ
ð Ô(¨4Ñ/ðZ
ð  %Ô0°4Ñ7ðZ
ð !&Ô 1°DÑ 8ðZ
ð Ô  4Ñ'ðZ
ð   $™;ðZ
ð # T™kðZ
ð ˜D‘[ðZ
ð 
�Ñ	ðZ
ð Z
ð Z
ñ „^ðZ
ð Z
ð Z
ð Z
ð Z
r,   rD  a  
    Tapas Model with a cell selection head and optional aggregation head on top for question-answering tasks on tables
    (linear layers on top of the hidden-states output to compute `logits` and optional `logits_aggregation`), e.g. for
    SQA, WTQ or WikiSQL-supervised tasks.
    c            !       ó^  ‡ — e Zd Zdefˆ f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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z  fd„¦   «         Zˆ xZS )r#  rH   c                 ó   •— t          ¦   «                              |¦  «         t          |¦  «        | _        t	          j        |j        ¦  «        | _        t	          j        t          j
        |j        ¦  «        ¦  «        | _        t	          j        t          j
        |j        ¦  «        ¦  «        | _        t	          j        t          j
        g ¦  «        ¦  «        | _        t	          j        t          j
        g ¦  «        ¦  «        | _        |j        dk    r$t	          j        |j        |j        ¦  «        | _        |                      ¦   «          d S r  )r5   r6   r0  r  r   rE   rF   rG   r  r'   Úemptyr9   r%  r&  r)  r*  Únum_aggregation_labelsr~   Úaggregation_classifierr4  r¶   s     €r-   r6   z"TapasForQuestionAnswering.__init__  sø   ø€ Ý‰Œ×Ò˜Ñ Ô Ð õ   Ñ'Ô'ˆŒ
õ ”z &Ô"<Ñ=Ô=ˆŒõ !œl­5¬;°vÔ7IÑ+JÔ+JÑKÔKˆÔÝ%'¤\µ%´+¸fÔ>PÑ2QÔ2QÑ%RÔ%RˆÔ"Ýœ<­¬°B©¬Ñ8Ô8ˆÔÝ"$¤,­u¬{¸2©¬Ñ"?Ô"?ˆÔð Ô(¨1Ò,Ð,Ý*,¬)°FÔ4FÈÔHeÑ*fÔ*fˆDÔ'ð 	�ŠÑÔÐÐÐr,   Nrd   r�   re   rf   rg   Ú
table_maskrL  Úaggregation_labelsÚfloat_answerÚnumeric_valuesÚnumeric_values_scaler    rø   rù   r¸   c           
      ó,  — |�|n| j         j        }|                      ||||||||¬¦  «        }|d         }|d         }|                      |¦  «        }|�|                     ¦   «         }n|                     ¦   «         dd…         }|�|j        n|j        }|€=t          j        g |¢t          | j         j	        ¦  «        ‘R t          j
        |¬¦  «        }g d¢}|dd…dd…|                     d¦  «        f         }|dd…dd…|                     d	¦  «        f         }t          t          j        |t          j        | j         j        dz
  |j        ¬
¦  «        ¦  «        | j         j        d¬¦  «        }t          t          j        |t          j        | j         j        dz
  |j        ¬
¦  «        ¦  «        | j         j        d¬¦  «        }t#          ||¦  «        }|�|                     ¦   «         n|                     ¦   «         dd…         }|�|j        n|j        }|€t          j        ||¬
¦  «        }|€>t          j        |dk    t          j        |¦  «        t          j        |¦  «        ¦  «        }|                     |t          j        ¬¦  «        }|                     |t          j        ¬¦  «        }t1          ||¦  «        \  }}t3          || j         j        | j        | j        ¦  «        }d} | j         j        r(t=          || j        | j         ||| j         j!        ¦  «        } d}!| j         j"        dk    r|  #                    |¦  «        }!d}"d}#|��^d}#| j         j"        dk     p| j         j$         }$|$rd}%nZ|	�I|j%        d         |	j%        d         k    s
J d¦   «         ‚tM          |	|| j         j'        || j#        ¦  «        }%ntQ          d¦  «        ‚| j         j)        r#t1          ||¦  «        \  }&}tU          |&|¦  «        }t          j+         ,                    |¬¦  «        }'d}(| j         j        sµt          j        |dk    t          j        |t          j-        ¬¦  «        | j         j.        t          j        |t          j-        ¬¦  «        z  ¦  «        })|' /                    |¦  «         |)z  }*t          j0        |*|z  d¬¦  «        t          j0        |d¬¦  «        tb          z   z  }(n7te          || ||||¦  «        \  }(}t          j+         ,                    |¬¦  «        }'| j         j3        rn7|$r|"t          j4        |(¦  «        z  }"n|"t          j4        |(d|%z
  z  ¦  «        z  }"| j         j"        dk    �r@|$rj|�Y|j%        d         |j%        d         k    s
J d¦   «         ‚tk          |!|%|| j         j$        | j         j"        | j         j6        ¦  «        }+nrtQ          d¦  «        ‚t          j        |j%        d         t          j
        |j        ¬¦  «        }tk          |!|%|| j         j$        | j         j"        | j         j6        ¦  «        }+| j         j$        rN|
�=|�;|
j%        |j%        k    sJ ‚to          |	|%|'|
|||!| j         ¦  «        \  },}-|+|,z  }+|+|-z  }+ntQ          d¦  «        ‚|"t          j4        |+¦  «        z  }"n+t          j        |¦  «        }te          || ||||¦  «        \  }}|s||!f|dd…         z   }.|#r|"f|.z   n|.S tq          |#r|"nd||!|j9        |j:        ¬¦  «        S )ad  
        token_type_ids (`torch.LongTensor` of shape `(batch_size, sequence_length, 7)`, *optional*):
            Token indices that encode tabular structure. Indices can be obtained using [`AutoTokenizer`]. See this
            class for more info.

            [What are token type IDs?](../glossary#token-type-ids)
        position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
            Indices of positions of each input sequence tokens in the position embeddings. If
            `reset_position_index_per_cell` of [`TapasConfig`] is set to `True`, relative position embeddings will be
            used. Selected in the range `[0, config.max_position_embeddings - 1]`.

            [What are position IDs?](../glossary#position-ids)
        table_mask (`torch.LongTensor` of shape `(batch_size, seq_length)`, *optional*):
            Mask for the table. Indicates which tokens belong to the table (1). Question tokens, table headers and
            padding are 0.
        labels (`torch.LongTensor` of shape `(batch_size, seq_length)`, *optional*):
            Labels per token for computing the hierarchical cell selection loss. This encodes the positions of the
            answer appearing in the table. Can be obtained using [`AutoTokenizer`].

            - 1 for tokens that are **part of the answer**,
            - 0 for tokens that are **not part of the answer**.
        aggregation_labels (`torch.LongTensor` of shape `(batch_size, )`, *optional*):
            Aggregation function index for every example in the batch for computing the aggregation loss. Indices
            should be in `[0, ..., config.num_aggregation_labels - 1]`. Only required in case of strong supervision for
            aggregation (WikiSQL-supervised).
        float_answer (`torch.FloatTensor` of shape `(batch_size, )`, *optional*):
            Float answer for every example in the batch. Set to *float('nan')* for cell selection questions. Only
            required in case of weak supervision (WTQ) to calculate the aggregate mask and regression loss.
        numeric_values (`torch.FloatTensor` of shape `(batch_size, seq_length)`, *optional*):
            Numeric values of every token, NaN for tokens which are not numeric values. Can be obtained using
            [`AutoTokenizer`]. Only required in case of weak supervision for aggregation (WTQ) to calculate the
            regression loss.
        numeric_values_scale (`torch.FloatTensor` of shape `(batch_size, seq_length)`, *optional*):
            Scale of the numeric values of every token. Can be obtained using [`AutoTokenizer`]. Only required in case
            of weak supervision for aggregation (WTQ) to calculate the regression loss.

        Examples:

        ```python
        >>> from transformers import AutoTokenizer, TapasForQuestionAnswering
        >>> import pandas as pd

        >>> tokenizer = AutoTokenizer.from_pretrained("google/tapas-base-finetuned-wtq")
        >>> model = TapasForQuestionAnswering.from_pretrained("google/tapas-base-finetuned-wtq")

        >>> data = {
        ...     "Actors": ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"],
        ...     "Age": ["56", "45", "59"],
        ...     "Number of movies": ["87", "53", "69"],
        ... }
        >>> table = pd.DataFrame.from_dict(data)
        >>> queries = ["How many movies has George Clooney played in?", "How old is Brad Pitt?"]

        >>> inputs = tokenizer(table=table, queries=queries, padding="max_length", return_tensors="pt")
        >>> outputs = model(**inputs)

        >>> logits = outputs.logits
        >>> logits_aggregation = outputs.logits_aggregation
        ```N©r�   re   rf   rg   r    rø   rù   r   r   rN   rO   )Úsegment_idsÚ
column_idsÚrow_idsÚprev_labelsÚcolumn_ranksÚinv_column_ranksÚnumeric_relationsr`  r_  rT   ©ÚindicesÚnum_segmentsrR   )rQ   rP   g        FTz>Make sure the answers are a FloatTensor of shape (batch_size,)zJYou have to specify float answers in order to calculate the aggregate mask©r   ©rP   rˆ   ç      ð?zHMake sure the aggregation labels are a LongTensor of shape (batch_size,)zQYou have to specify aggregation labels in order to calculate the aggregation losszeYou have to specify numeric values and numeric values scale in order to calculate the regression lossrS   )r   r   r    r!   r"   );rH   rù   r  rG   rU   rQ   r'   ra   rA   r?   rW   Úindexr[   r_   r`   Úmax_num_rowsÚmax_num_columnsr\   r?  ÚwhereÚ	ones_likeÚ
zeros_likeÚtoÚfloatÚreduce_meanÚcompute_token_logitsÚtemperaturer%  r)  Úselect_one_columnÚcompute_column_logitsr&  r*  Úallow_empty_column_selectionrU  rV  Úuse_answer_as_supervisionrŠ   Ú_calculate_aggregate_maskÚcell_selection_preferencerz   Úaverage_logits_per_cellr^   ÚdistributionsÚ	BernoulliÚfloat32Úpositive_label_weightÚlog_probÚsumÚEPSILON_ZERO_DIVISIONÚ"_single_column_cell_selection_lossÚdisable_per_token_lossÚmeanÚ_calculate_aggregation_lossÚaggregation_loss_weightÚ_calculate_regression_lossr   r!   r"   )/rI   rd   r�   re   rf   rg   rW  rL  rX  rY  rZ  r[  r    rø   rù   r¡   r­   r  r  rh   rQ   Útoken_typesr`  r_  rk   rj   Ú
cell_indexÚinput_mask_floatÚtable_mask_floatÚ	cell_maskÚ_r   Úcolumn_logitsr    Ú
total_lossÚcalculate_lossÚis_supervisedÚaggregate_maskÚlogits_per_cellÚdist_per_tokenÚselection_loss_per_exampleÚweightÚselection_loss_per_tokenÚper_example_additional_lossÚanswer_lossÚlarge_answer_loss_maskrÄ   s/                                                  r-   rq   z!TapasForQuestionAnswering.forward(  sú  € ð\ &1Ð%<�k�kÀ$Ä+ÔBYˆà—*’*ØØ)Ø)Ø%Ø'Ø/Ø!5Ø#ð ñ 	
ô 	
ˆð " !œ*ˆØ œ
ˆàŸ,š, Ñ7Ô7ˆàÐ Ø#Ÿ.š.Ñ*Ô*ˆKˆKà'×,Ò,Ñ.Ô.¨s°¨sÔ3ˆKà%.Ð%:�Ô!Ð!ÀÔ@Tˆð Ð!Ý"œ[ØA�+ÐA�s 4¤;Ô#?Ñ@Ô@ÐAÐAÍÌÐ\bðñ ô ˆNð
ð 
ð 
ˆð !    A A A {×'8Ò'8¸Ñ'CÔ'CÐ!CÔDˆØ# A A A q q q¨+×*;Ò*;¸LÑ*IÔ*IÐ$IÔJˆ
åÝ”I˜g¥u¤°t´{Ô7OÐRSÑ7SÐ\cÔ\jÐ'kÑ'kÔ'kÑlÔlØœÔ1Øð
ñ 
ô 
ˆ	õ
 Ý”I˜j­%¬/¸$¼+Ô:UÐXYÑ:YÐblÔbsÐ*tÑ*tÔ*tÑuÔuØœÔ4Øð
ñ 
ô 
ˆ	õ
 % Y°	Ñ:Ô:ˆ
ð +4Ð*?�i—n’nÑ&Ô&Ð&À]×EWÒEWÑEYÔEYÐZ]Ð[]ÐZ]ÔE^ˆØ%.Ð%:�Ô!Ð!ÀÔ@TˆØÐ!Ý"œZ¨¸FÐCÑCÔCˆNàÐÝœ W¨q¢[µ%´/À'Ñ2JÔ2JÍEÔL\Ð]dÑLeÔLeÑfÔfˆJà)×,Ò,°FÅ%Ä+Ð,ÑNÔNÐØ%Ÿ=š=°½e¼k˜=ÑJÔJÐå"Ð#3°ZÑ@Ô@‰ˆ	�1õ & o°t´{Ô7NÐPTÔPcÐeiÔeuÑvÔvˆð ˆØŒ;Ô(ð 	Ý1ØØÔ*ØÔ'ØØØ”Ô8ñô ˆMð "ÐØŒ;Ô-°Ò1Ð1Ø!%×!<Ò!<¸]Ñ!KÔ!KÐð ˆ
ØˆØÑØ!ˆNØ $¤Ô BÀQÒ FÐFÐsÈdÌkÔNsÐJsˆMð ð sØ!%��àÐ+Ø!œ<¨œ?¨lÔ.@ÀÔ.CÒCÐCÐCØXñ DÔCÐCõ &?Ø$Ø%ØœÔ=ØØÔ3ñ&ô &�N�Nõ %Ð%qÑrÔrÐrð Œ{Ô2ð =Ý%0°¸Ñ%DÔ%DÑ"� Ý °Ñ<Ô<�Ý"Ô0×:Ò:À&Ð:ÑIÔIˆNð *.Ð&Ø”;Ô0ð NÝœØ˜a’KÝ”O Fµ%´-Ð@Ñ@Ô@Ø”KÔ5½¼ÈÕV[ÔVcÐ8dÑ8dÔ8dÑdñô �ð
 -;×,CÒ,CÀFÑ,KÔ,KÐ+KÈfÑ+TÐ(Ý-2¬YÐ7OÐRbÑ7bÐhiÐ-jÑ-jÔ-jÝ”IÐ.°AÐ6Ñ6Ô6Õ9NÑNñ.Ð*Ð*õ 6XØ˜M¨6°:¸yÈ)ñ6ô 6Ñ2Ð*¨Fõ "'Ô!4×!>Ò!>ÀfÐ!>Ñ!MÔ!M�ð Œ{Ô1ð ^ØØð ^Ø�eœjÐ)CÑDÔDÑD�
�
ð �eœjÐ)CÀsÈ^ÑG[Ñ)\Ñ]Ô]Ñ]�
ð Œ{Ô1°AÒ5Ñ5Ø ð à)Ð5Ø%œ|¨AœÐ2DÔ2JÈ1Ô2MÒMÐMÐMØfñ  NÔMÐMõ 7RØ.Ø*Ø.Ø œKÔAØ œKÔ>Ø œKÔ?ñ7ô 7Ð3Ð3õ )Øoñô ð õ
 */¬°V´\À!´_ÍEÌJÐ_eÔ_lÐ)mÑ)mÔ)mÐ&Ý2MØ*Ø&Ø*ØœÔ=ØœÔ:ØœÔ;ñ3ô 3Ð/ð ”;Ô8ð Ø%Ð1Ð6JÐ6VØ-Ô3Ð7KÔ7QÒQÐQÐQÐQå>XØ(Ø*Ø*Ø*Ø0Ø,Ø.Ø œKñ	?ô 	?Ñ;˜Ð%;ð 4°{ÑBÐ3à3Ð7MÑMÐ3Ð3å(ð/ñô ð ð
 �eœjÐ)DÑEÔEÑE�
øõ Ô% fÑ-Ô-ˆFÝ:Ø˜ v¨z¸9Àiñô ‰IˆAˆvð ð 	JØÐ0Ð1°G¸A¸B¸B´KÑ?ˆFØ/=ÐI�Z�M FÑ*Ð*À6ÐIå+Ø-Ð7��°4ØØ1Ø!Ô/ØÔ)ð
ñ 
ô 
ð 	
r,   )NNNNNNNNNNNNNN)r#   r$   r%   r   r6   r   r'   rB  r(   rÉ   r*   r   rq   rr   rs   s   @r-   r#  r#  
  s«  ø€ € € € € ð˜{ð ð ð ð ð ð ð, ð .2Ø37Ø26Ø04Ø26Ø.2Ø*.Ø6:Ø15Ø37Ø9=Ø)-Ø,0Ø#'ðq
ð q
àÔ# dÑ*ðq
ð Ô)¨DÑ0ðq
ð Ô(¨4Ñ/ð	q
ð
 Ô&¨Ñ-ðq
ð Ô(¨4Ñ/ðq
ð Ô$ tÑ+ðq
ð Ô  4Ñ'ðq
ð "Ô,¨tÑ3ðq
ð Ô'¨$Ñ.ðq
ð Ô)¨DÑ0ðq
ð $Ô/°$Ñ6ðq
ð   $™;ðq
ð # T™kðq
ð ˜D‘[ðq
ð" 
Ð-Ñ	-ð#q
ð q
ð q
ñ „^ðq
ð q
ð q
ð q
ð q
r,   r#  z¸
    Tapas Model with a sequence classification head on top (a linear layer on top of the pooled output), e.g. for table
    entailment tasks, such as TabFact (Chen et al., 2020).
    c                   ó   ‡ — e Zd Zˆ f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dz  d
edz  dedz  de	ej
                 ez  fd„¦   «         Zˆ xZS )ÚTapasForSequenceClassificationc                 ó6  •— t          ¦   «                              |¦  «         |j        | _        t          |¦  «        | _        t          j        |j        ¦  «        | _        t          j	        |j
        |j        ¦  «        | _        |                      ¦   «          d S r®   )r5   r6   Ú
num_labelsr0  r  r   rE   rF   rG   r~   r9   Ú
classifierr4  r¶   s     €r-   r6   z'TapasForSequenceClassification.__init__d  sy   ø€ Ý‰Œ×Ò˜Ñ Ô Ð Ø Ô+ˆŒå Ñ'Ô'ˆŒ
Ý”z &Ô"<Ñ=Ô=ˆŒÝœ) FÔ$6¸Ô8IÑJÔJˆŒð 	�ŠÑÔÐÐÐr,   Nrd   r�   re   rf   rg   rL  r    rø   rù   r¸   c
           
      óì  — |	�|	n| j         j        }	|                      ||||||||	¬¦  «        }|d         }|                      |¦  «        }|                      |¦  «        }d}|��Z| j         j        €f| j        dk    rd| j         _        nN| j        dk    r7|j        t          j	        k    s|j        t          j
        k    rd| j         _        nd| j         _        | j         j        dk    rWt          ¦   «         }| j        dk    r1 ||                     ¦   «         |                     ¦   «         ¦  «        }nŽ |||¦  «        }n�| j         j        dk    rGt          ¦   «         } ||                     d| j        ¦  «        |                     d¦  «        ¦  «        }n*| j         j        dk    rt          ¦   «         } |||¦  «        }|	s|f|dd…         z   }|�|f|z   n|S t!          |||j        |j        ¬	¦  «        S )
aV	  
        token_type_ids (`torch.LongTensor` of shape `(batch_size, sequence_length, 7)`, *optional*):
            Token indices that encode tabular structure. Indices can be obtained using [`AutoTokenizer`]. See this
            class for more info.

            [What are token type IDs?](../glossary#token-type-ids)
        position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
            Indices of positions of each input sequence tokens in the position embeddings. If
            `reset_position_index_per_cell` of [`TapasConfig`] is set to `True`, relative position embeddings will be
            used. Selected in the range `[0, config.max_position_embeddings - 1]`.

            [What are position IDs?](../glossary#position-ids)
        labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
            Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
            config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
            `config.num_labels > 1` a classification loss is computed (Cross-Entropy). Note: this is called
            "classification_class_index" in the original implementation.

        Examples:

        ```python
        >>> from transformers import AutoTokenizer, TapasForSequenceClassification
        >>> import torch
        >>> import pandas as pd

        >>> tokenizer = AutoTokenizer.from_pretrained("google/tapas-base-finetuned-tabfact")
        >>> model = TapasForSequenceClassification.from_pretrained("google/tapas-base-finetuned-tabfact")

        >>> data = {
        ...     "Actors": ["Brad Pitt", "Leonardo Di Caprio", "George Clooney"],
        ...     "Age": ["56", "45", "59"],
        ...     "Number of movies": ["87", "53", "69"],
        ... }
        >>> table = pd.DataFrame.from_dict(data)
        >>> queries = [
        ...     "There is only one actor who is 45 years old",
        ...     "There are 3 actors which played in more than 60 movies",
        ... ]

        >>> inputs = tokenizer(table=table, queries=queries, padding="max_length", return_tensors="pt")
        >>> labels = torch.tensor([1, 0])  # 1 means entailed, 0 means refuted

        >>> outputs = model(**inputs, labels=labels)
        >>> loss = outputs.loss
        >>> logits = outputs.logits
        ```Nr]  r   Ú
regressionÚsingle_label_classificationÚmulti_label_classificationrN   rS   rN  )rH   rù   r  rG   r¡  Úproblem_typer   rP   r'   rW   r{   r   Úsqueezer   r‹   r   r   r!   r"   )rI   rd   r�   re   rf   rg   rL  r    rø   rù   r¡   r­   r  r   r   rP  rÄ   s                    r-   rq   z&TapasForSequenceClassification.forwardo  s  € ðx &1Ð%<�k�kÀ$Ä+ÔBYˆà—*’*ØØ)Ø)Ø%Ø'Ø/Ø!5Ø#ð ñ 	
ô 	
ˆð   œ
ˆàŸš ]Ñ3Ô3ˆØ—’ Ñ/Ô/ˆàˆØÑØŒ{Ô'Ð/Ø”? aÒ'Ð'Ø/;�D”KÔ,Ð,Ø”_ qÒ(Ð(¨f¬l½e¼jÒ.HÐ.HÈFÌLÕ\aÔ\eÒLeÐLeØ/L�D”KÔ,Ð,à/K�D”KÔ,àŒ{Ô'¨<Ò7Ð7Ý"™9œ9�Ø”? aÒ'Ð'Ø#˜8 F§N¢NÑ$4Ô$4°f·n²nÑ6FÔ6FÑGÔG�D�Dà#˜8 F¨FÑ3Ô3�D�DØ”Ô)Ð-JÒJÐJÝ+Ñ-Ô-�Ø�x §¢¨B°´Ñ @Ô @À&Ç+Â+ÈbÁ/Ä/ÑRÔR��Ø”Ô)Ð-IÒIÐIÝ,Ñ.Ô.�Ø�x ¨Ñ/Ô/�Øð 	FØ�Y ¨¨¨¤Ñ,ˆFØ)-Ð)9�T�G˜fÑ$Ð$¸vÐEå'ØØØ!Ô/ØÔ)ð	
ñ 
ô 
ð 	
r,   )	NNNNNNNNN)r#   r$   r%   r6   r   r'   rB  r(   rÉ   r*   r¾   r   rq   rr   rs   s   @r-   rž  rž  ]  s8  ø€ € € € € ð	ð 	ð 	ð 	ð 	ð ð .2Ø37Ø26Ø04Ø26Ø*.Ø)-Ø,0Ø#'ðl
ð l
àÔ# dÑ*ðl
ð Ô)¨DÑ0ðl
ð Ô(¨4Ñ/ð	l
ð
 Ô&¨Ñ-ðl
ð Ô(¨4Ñ/ðl
ð Ô  4Ñ'ðl
ð   $™;ðl
ð # T™kðl
ð ˜D‘[ðl
ð 
ˆuŒ|Ô	Ð7Ñ	7ðl
ð l
ð l
ñ „^ðl
ð l
ð l
ð l
ð l
r,   rž  c                   ó   — e Zd ZdZdZdZdS )ÚAverageApproximationFunctionÚratioÚfirst_orderÚsecond_orderN)r#   r$   r%   ÚRATIOÚFIRST_ORDERÚSECOND_ORDERr+   r,   r-   r©  r©  â  s   € € € € € Ø€EØ€KØ!€L€L€Lr,   r©  c                   ó    — e Zd ZdZdd„Zd„ ZdS )r[   z'Index grouping entries within a tensor.r   c                 ó”   — t          j        ||j        ¬¦  «        | _        t          j        ||j        ¬¦  «        | _        || _        dS )aò  
        Creates an index

        Args:
            indices (`torch.LongTensor`, same shape as a *values* Tensor to which the indices refer):
                Tensor containing the indices.
            num_segments (`torch.LongTensor`):
                Scalar tensor, the number of segments. All elements in a batched segmented tensor must have the same
                number of segments (although many segments can be empty).
            batch_dims (`int`, *optional*, defaults to 0):
                The number of batch dimensions. The first *batch_dims* dimensions of a SegmentedTensor are treated as
                batch dimensions. Segments in different batch elements are always distinct even if they have the same
                index.
        rT   N)r'   r`   rQ   rf  rg  rR   )rI   rf  rg  rR   s       r-   r6   zIndexMap.__init__î  s@   € õ ” w°w´~ÐFÑFÔFˆŒÝ!œO¨LÀÄÐPÑPÔPˆÔØ$ˆŒˆˆr,   c                 óN   — | j                              ¦   «         d | j        …         S r®   )rf  rU   rR   r8  s    r-   Úbatch_shapezIndexMap.batch_shape  s#   € ØŒ|× Ò Ñ"Ô"Ð#4 T¤_Ð#4Ô5Ð5r,   N)r   )r#   r$   r%   r&   r6   r³  r+   r,   r-   r[   r[   ë  s=   € € € € € Ø1Ð1ð%ð %ð %ð %ð&6ð 6ð 6ð 6ð 6r,   r[   c                   ó.   ‡ — e Zd ZdZˆ fd„Zd„ Zd„ Zˆ xZS )r\   zThe product of two indices.c                 óø   •— |j         |j         k    rt          d¦  «        ‚t          ¦   «                              |j        |j        |j        z  z   |j        |j        z  |j         ¬¦  «         || _        || _        dS )aÎ  
        Combines indices i and j into pairs (i, j). The result is an index where each segment (i, j) is the
        intersection of segments i and j. For example if the inputs represent table cells indexed by respectively rows
        and columns the output will be a table indexed by (row, column) pairs, i.e. by cell. The implementation
        combines indices {0, .., n - 1} and {0, .., m - 1} into {0, .., nm - 1}. The output has *num_segments* equal to
        *outer_index.num_segments* * *inner_index.num_segments*

        Args:
            outer_index (`IndexMap`):
                IndexMap.
            inner_index (`IndexMap`):
                IndexMap, must have the same shape as *outer_index*.
        zCouter_index.batch_dims and inner_index.batch_dims must be the same.re  N)rR   rz   r5   r6   rf  rg  Úouter_indexÚinner_index)rI   r¶  r·  rL   s      €r-   r6   zProductIndexMap.__init__  sˆ   ø€ ð Ô! [Ô%;Ò;Ð;ÝÐbÑcÔcÐcå‰Œ×ÒØ Ô(¨;Ô+>ÀÔAYÑ+YÑYØ$Ô1°KÔ4LÑLØ"Ô-ð 	ñ 	
ô 	
ð 	
ð
 'ˆÔØ&ˆÔÐÐr,   c                 óÊ   — t          j        |j        | j        j        d¬¦  «                             t           j        ¦  «        }t          || j        j        |j	        ¬¦  «        S )zDProjects an index with the same index set onto the outer components.Úfloor)Úrounding_modere  )
r'   Údivrf  r·  rg  ÚtyperW   r[   r¶  rR   )rI   rk  rf  s      r-   Úproject_outerzProductIndexMap.project_outer!  sR   € å”)˜EœM¨4Ô+;Ô+HÐX_Ð`Ñ`Ô`×eÒeÕfkÔfpÑqÔqˆÝ °dÔ6FÔ6SÐ`eÔ`pÐqÑqÔqÐqr,   c                 ó   — t          t          j        |j        | j        j        ¦  «                             t          j        ¦  «                             ¦   «                              t          j	        ¦  «        | j        j        |j
        ¬¦  «        S )zDProjects an index with the same index set onto the inner components.re  )r[   r'   Úfmodrf  r·  rg  r¼  rr  r¹  rW   rR   )rI   rk  s     r-   Úproject_innerzProductIndexMap.project_inner&  sf   € åÝ”J˜uœ}¨dÔ.>Ô.KÑLÔLßŠT•%”+ÑÔßŠU‰WŒWßŠT•%”*ÑÔØÔ)Ô6ØÔ'ð
ñ 
ô 
ð 	
r,   )r#   r$   r%   r&   r6   r½  rÀ  rr   rs   s   @r-   r\   r\     s_   ø€ € € € € Ø%Ð%ð'ð 'ð 'ð 'ð 'ð2rð rð rð
	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
r,   r\   Úsegmented_gatherc                 óÂ  — |j         }t          | j        |j        d…         ¦  «        dk     rlt	          j        | |j        |                     |                      ¦   «         d         d¦  «        ¦  «                             |                     ¦   «         ¦  «        S |                     d¦  «         	                    | j        ¦  «        }t	          j        | |j        |¦  «        S )a·  
    Gathers from *values* using the index map. For each element in the domain of the index map this operation looks up
    a value for that index in *values*. Two elements from the same segment always get assigned the same value.

    Args:
        values (`torch.Tensor` of shape (B1, ..., Bn, num_segments, V1, ...)):
            Tensor with segment values.
        index (`IndexMap` of shape (B1, ..., Bn, I1, ..., Ik)):
            IndexMap.
        name (`str`, *optional*, defaults to 'segmented_gather'):
            Name for the operation. Currently not used

    Returns:
        `tuple(torch.Tensor)`: Tensor of shape (B1, ..., Bn, I1, ..., Ik, V1, ...) with the gathered values.
    NrS   r   rN   )
rf  rA   rŠ   rR   r'   r^   r‹   rU   rX   rY   )r”   rk  rK   rf  s       r-   r^   r^   2  sÁ   € ð  Œm€Gå
ˆ6Œ<˜Ô(Ð*Ð*Ô+Ñ,Ô,¨qÒ0Ð0ÝŒ|ØØÔØ�LŠLØ—’‘”˜aÔ  "ñô ñ
ô 
÷ Š$ˆw�|Š|‰~Œ~Ñ
Ô
ð	ð ×#Ò# BÑ'Ô'×.Ò.¨v¬|Ñ<Ô<ˆÝŒ|˜F EÔ$4°gÑ>Ô>Ð>r,   Úsegmented_flattenc                 ó<  — t          j        t          j        t          |                      ¦   «         ¦  «        ¦  «        ¦  «        }t          j        d|| j        j        ¬¦  «        | j        z  }|                     |                      ¦   «         ¦  «        }t          | j
        t          | j                             ¦   «         ¦  «        ¦  «        D ]}|                     d¦  «        }Œ|| j        z   }t          |                     d¦  «        | j        |z  d¬¦  «        S )aj  
    Flattens a batched index map (which is typically of shape batch_size, seq_length) to a 1d index map. This operation
    relabels the segments to keep batch elements distinct. The k-th batch element will have indices shifted by
    *num_segments* * (k - 1). The result is a tensor with *num_segments* multiplied by the number of elements in the
    batch.

    Args:
        index (`IndexMap`):
            IndexMap to flatten.
        name (`str`, *optional*, defaults to 'segmented_flatten'):
            Name for the operation. Currently not used

    Returns:
        (`IndexMap`): The flattened IndexMap.
    r   ©ÚstartÚendrQ   rN   re  )r'   ÚprodÚtensorÚlistr³  rV   rg  rQ   r‹   rb   rR   rA   rf  rU   rX   r[   )rk  rK   Ú
batch_sizeÚoffsetr�  rf  s         r-   ÚflattenrÍ  S  só   € õ" ”�EœL­¨e×.?Ò.?Ñ.AÔ.AÑ)BÔ)BÑCÔCÑDÔD€Jõ Œ\  z¸%Ô:LÔ:SÐTÑTÔTÐW\ÔWiÑi€FØ�[Š[˜×*Ò*Ñ,Ô,Ñ-Ô-€FÝ�5Ô#¥S¨¬×);Ò);Ñ)=Ô)=Ñ%>Ô%>Ñ?Ô?ð &ð &ˆØ×!Ò! "Ñ%Ô%ˆˆà�u”}Ñ$€GÝ˜GŸLšL¨Ñ,Ô,¸5Ô;MÐPZÑ;ZÐghÐiÑiÔiÐir,   Úrange_index_mapc                 óš  — t          j        |¦  «        r|j        nd}t          j        | t           j        |¬¦  «        } t          |                      ¦   «         ¦  «        dk    sJ ‚t          j        ||¬¦  «        }t          |                     ¦   «         ¦  «        dk    sJ ‚t          j        d||j        ¬¦  «        }t          j        t          j	        | t           j        |j        ¬¦  «        | 
                    d¬¦  «        gd¬¦  «        }d„ |                     ¦   «         D ¦   «         }|                     |¦  «        }t          j        | t          j        dg|¬¦  «        gd¬¦  «        }|                     |                     ¦   «         ¦  «        }t          ||t          |                      ¦   «         ¦  «        d         ¬	¦  «        S )
a©  
    Constructs an index map equal to range(num_segments).

    Args:
        batch_shape (`torch.Size`):
            Batch shape
        num_segments (`int`):
            Number of segments
        name (`str`, *optional*, defaults to 'range_index_map'):
            Name for the operation. Currently not used

    Returns:
        (`IndexMap`): IndexMap of shape batch_shape with elements equal to range(num_segments).
    ÚcpurO   r   rT   r   rÅ  rˆ   c                 ó,   — g | ]}t          |¦  «        ‘ŒS r+   )r{   )rì   Úxs     r-   rí   z#range_index_map.<locals>.<listcomp>‘  s   € Ð5Ð5Ð5˜A•�Q‘”Ð5Ð5Ð5r,   re  )r'   Ú	is_tensorrQ   r`   rW   rA   rU   rV   Úcatro  rX   Útolistr‹   Úrepeatr[   rÊ  )r³  rg  rK   rQ   rf  Ú
new_tensorÚ	new_shapeÚ	multipless           r-   rÎ  rÎ  p  sÀ  € õ %*¤O°LÑ$AÔ$AÐLˆ\Ô Ð Àu€FÝ”/Ø�5œ:¨fðñ ô €Kõ ˆ{×ÒÑ!Ô!Ñ"Ô" aÒ'Ð'Ð'Ð'Ý”?Ø˜Vðñ ô €Lõ ˆ|× Ò Ñ"Ô"Ñ#Ô# qÒ(Ð(Ð(Ð(åŒlØ�\¨,Ô*=ðñ ô €Gõ ”Ý	Œ˜­E¬J¸|Ô?RÐ	SÑ	SÔ	SÐUa×UkÒUkÐpqÐUkÑUrÔUrÐsØðñ ô €Jð
 6Ð5 ×!2Ò!2Ñ!4Ô!4Ð5Ñ5Ô5€IØ�lŠl˜9Ñ%Ô%€Gå”	˜;­¬¸¸ÀFÐ(KÑ(KÔ(KÐLÐRSÐTÑTÔT€IØ�nŠn˜Y×-Ò-Ñ/Ô/Ñ0Ô0€Gõ ˜G°,Í4ÐP[×P`ÒP`ÑPbÔPbÑKcÔKcÐdeÔKfÐgÑgÔgÐgr,   c           	      óà  — t          |¦  «        }|                      ¦   «         t          |j                             ¦   «         ¦  «        d…         }t	          j        t	          j        dgt          j        ¬¦  «        t	          j        |t          j        ¬¦  «        gd¬¦  «        }|                      | 	                    ¦   «         ¦  «        }t	          j
        t          |j        ¦  «        t          j        |j        ¬¦  «        }|                     d|j                             ¦   «         |                     ¦   «         |d¬¦  «        }	|j        j        }
t	          j        t	          j        |                     ¦   «         t          j        |
¬¦  «        t	          j        |j        t          j        |
¬¦  «                             d¬¦  «        t	          j        |t          j        |
¬¦  «        gd¬¦  «        }|	                     ¦   «                              | 	                    ¦   «         ¦  «                             | j        ¦  «        }t-          |                     ¦   «         |j        ¦  «        }||fS )	aè  
    Applies a segment reduction segment-wise.

    Args:
        values (`torch.Tensor`):
            Tensor with segment values.
        index (`IndexMap`):
            IndexMap.
        segment_reduce_fn (`str`):
            Name for the reduce operation. One of "sum", "mean", "max" or "min".
        name (`str`):
            Name for the operation. Currently not used

    Returns:
        (`IndexMap`): IndexMap of shape batch_shape with elements equal to range(num_segments).
    NrN   ri  r   rˆ   rO   F)r‰   rk  ÚsrcÚreduceÚinclude_self)rÍ  rU   rA   rf  r'   rÔ  r`   rW   ÚreshaperÕ  ra   r{   rg  rr  rQ   Úscatter_reducer³  rX   Úcloner‹   rq  rP   rÎ  )r”   rk  Úsegment_reduce_fnrK   Ú
flat_indexÚvector_shapeÚflattened_shapeÚflat_valuesÚoutÚsegment_meansrQ   rØ  Úoutput_valuesÚoutput_indexs                 r-   Ú_segment_reducerê  œ  s  € õ( ˜‘”€JØ—;’;‘=”=¥ U¤]×%7Ò%7Ñ%9Ô%9Ñ!:Ô!:Ð!<Ð!<Ô=€LÝ”iÝ	Œ˜"˜¥U¤ZÐ	0Ñ	0Ô	0µ%´/À,ÕV[ÔV`Ð2aÑ2aÔ2aÐbÐhiðñ ô €Oð —.’. ×!7Ò!7Ñ!9Ô!9Ñ:Ô:€Kå
Œ+•c˜*Ô1Ñ2Ô2½%¼+ÈkÔN`Ð
aÑ
aÔ
a€CØ×&Ò&Ø�ZÔ'×,Ò,Ñ.Ô.°K×4EÒ4EÑ4GÔ4GÐPaÐpuð 'ñ ô €Mð ÔÔ&€Få”	åŒO˜E×-Ò-Ñ/Ô/µu´zÈ&ÐQÑQÔQÝŒO˜EÔ.µe´jÈÐPÑPÔP×ZÒZÐ_`ÐZÑaÔaÝŒO˜Lµ´
À6ÐJÑJÔJð	
ð
 ðñ ô €Ið "×'Ò'Ñ)Ô)×.Ò.¨y×/?Ò/?Ñ/AÔ/AÑBÔB×EÒEÀfÄlÑSÔS€MÝ" 5×#4Ò#4Ñ#6Ô#6¸Ô8JÑKÔK€LØ˜,Ð&Ð&r,   Úsegmented_reduce_sumc                 ó&   — t          | |d|¦  «        S )a~  
    Sums a tensor over its segments.

    Outputs 0 for empty segments.

    This operations computes the sum over segments, with support for:

        - Batching using the first dimensions [B1, B2, ..., Bn]. Each element in a batch can have different indices.
        - Vectorization using the last dimension [V1, V2, ...]. If they are present, the output will be a sum of
          vectors rather than scalars. Only the middle dimensions [I1, ..., Ik] are reduced by the operation.

    Args:
        values (`torch.Tensor` of shape [B1, B2, ..., Bn, I1, .., Ik, V1, V2, ..]):
            Tensor containing the values of which the sum must be taken segment-wise.
        index (`IndexMap`, indices are of shape [B1, B2, ..., Bn, I1, .., Ik].):
            Index defining the segments.
        name (`str`, *optional*, defaults to 'segmented_reduce_sum'):
            Name for the operation. Currently not used

    Returns:
        output_values (`torch.Tensor`of shape [B1, B2, ..., Bn, num_segments, V1, V2, ..]): Tensor containing the
        output values. output_index (`IndexMap`): IndexMap with shape [B1, B2, ..., Bn, num_segments]. .
    r‚  ©rê  ©r”   rk  rK   s      r-   Ú
reduce_sumrï  Í  s   € õ0 ˜6 5¨%°Ñ6Ô6Ð6r,   Úsegmented_reduce_meanc                 ó&   — t          | |d|¦  «        S )aˆ  
    Averages a tensor over its segments.

    Outputs 0 for empty segments.

    This operations computes the mean over segments, with support for:

        - Batching using the first dimensions [B1, B2, ..., Bn]. Each element in a batch can have different indices.
        - Vectorization using the last dimension [V1, V2, ...]. If they are present, the output will be a mean of
          vectors rather than scalars.

    Only the middle dimensions [I1, ..., Ik] are reduced by the operation.

    Args:
        values (`torch.Tensor` of shape [B1, B2, ..., Bn, I1, .., Ik, V1, V2, ..]):
            Tensor containing the values of which the mean must be taken segment-wise.
        index (`IndexMap`, indices are of shape [B1, B2, ..., Bn, I1, .., Ik].):
            Index defining the segments.
        name (`str`, *optional*, defaults to 'segmented_reduce_sum'):
            Name for the operation. Currently not used

    Returns:
        output_values (`torch.Tensor`of shape [B1, B2, ..., Bn, num_segments, V1, V2, ..]): Tensor containing the
        output values. output_index (`IndexMap`): IndexMap with shape [B1, B2, ..., Bn, num_segments].
    r†  rí  rî  s      r-   rs  rs  è  s   € õ4 ˜6 5¨&°$Ñ7Ô7Ð7r,   Úsegmented_reduce_maxc                 ó&   — t          | |d|¦  «        S )av  
    Computes the maximum over segments.

    This operation computes the maximum over segments, with support for:

        - Batching using the first dimensions [B1, B2, ..., Bn]. Each element in a batch can have different indices.
        - Vectorization using the last dimension [V1, V2, ...]. If they are present, the output will be an element-wise
          maximum of vectors rather than scalars.

    Only the middle dimensions [I1, ..., Ik] are reduced by the operation.

    Args:
        values (`torch.Tensor` of shape [B1, B2, ..., Bn, I1, .., Ik, V1, V2, ..]):
            Tensor containing the values of which the max must be taken segment-wise.
        index (`IndexMap`, indices are of shape [B1, B2, ..., Bn, I1, .., Ik].):
            Index defining the segments.
        name (`str`, *optional*, defaults to 'segmented_reduce_sum'):
            Name for the operation. Currently not used

    Returns:
        output_values (`torch.Tensor`of shape [B1, B2, ..., Bn, num_segments, V1, V2, ..]): Tensor containing the
        output values. output_index (`IndexMap`): IndexMap with shape [B1, B2, ..., Bn, num_segments].
    Úamaxrí  rî  s      r-   Ú
reduce_maxrõ    ó   € õ0 ˜6 5¨&°$Ñ7Ô7Ð7r,   Úsegmented_reduce_minc                 ó&   — t          | |d|¦  «        S )aw  
    Computes the minimum over segments.

    This operations computes the minimum over segments, with support for:

        - Batching using the first dimensions [B1, B2, ..., Bn]. Each element in a batch can have different indices.
        - Vectorization using the last dimension [V1, V2, ...]. If they are present, the output will be an element-wise
          minimum of vectors rather than scalars.

    Only the middle dimensions [I1, ..., Ik] are reduced by the operation.

    Args:
        values (`torch.Tensor` of shape [B1, B2, ..., Bn, I1, .., Ik, V1, V2, ..]):
            Tensor containing the values of which the min must be taken segment-wise.
        index (`IndexMap`, indices are of shape [B1, B2, ..., Bn, I1, .., Ik].):
            Index defining the segments.
        name (`str`, *optional*, defaults to 'segmented_reduce_sum'):
            Name for the operation. Currently not used

    Returns:
        output_values (`torch.Tensor`of shape [B1, B2, ..., Bn, num_segments, V1, V2, ..]): Tensor containing the
        output values. output_index (`IndexMap`): IndexMap with shape [B1, B2, ..., Bn, num_segments].
    Úaminrí  rî  s      r-   r]   r]      rö  r,   c                 óZ  — t          j        d| |¦  «        |z   }t          ||¦  «        \  }}|                     |¦  «        }	t	          ||z  |	¦  «        \  }
}t	          ||	¦  «        \  }}|
|t
          z   z  }
t          j        |dk     t          j        |j        d¦  «         ¦  «        }|
t          t          j
        |t           j        |j        ¬¦  «        z  z  }
|sN|
t          t          j
        t          j        |j        d¦  «        t           j        |j        j        ¬¦  «        z  z  }
|
S )a)  
    Computes the column logits.

    Args:
        sequence_output (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
            Also known as last_hidden_state. Sequence of hidden-states at the output of the last layer of the model.
        column_output_weights (`torch.FloatTensor` of shape `(hidden_size)`):
            Weights of the linear layer for column selection.
        column_output_bias (`torch.FloatTensor` of shape `()`):
            Bias of the linear layer for column selection.
        cell_index (`ProductIndexMap`):
            Index that groups tokens into cells.
        cell_mask (`torch.FloatTensor` of shape `(batch_size, max_num_rows * max_num_cols)`):
            Mask for cells that exist in the table (i.e. that are not padding).
        allow_empty_column_selection (`bool`):
            Whether to allow not to select any column

    Returns:
        column_logits (`torch.FloatTensor`of shape `(batch_size, max_num_cols)`): Tensor containing the column logits
        for every example in the batch.
    ú	bsj,j->bsç      à?r   rO   )r'   Úeinsumrs  rÀ  rï  rƒ  Úlogical_andÚeqrf  ÚCLOSE_ENOUGH_TO_LOG_ZEROr`   r  rQ   )r  r&  r*  r‹  rŽ  rx  Útoken_logitsÚcell_logitsÚcell_logits_indexÚcolumn_indexr�  Ú	out_indexÚ
cell_countr�  Ú
is_paddings                  r-   rw  rw  >  s9  € õ4 ”< ¨_Ð>SÑTÔTÐWiÑi€Lõ &1°¸zÑ%JÔ%JÑ"€KÐ"ð ×+Ò+Ð,=Ñ>Ô>€LÝ)¨+¸	Ñ*AÀ<ÑPÔPÑ€M�9å˜y¨,Ñ7Ô7�M€J�Ø�ZÕ"7Ñ7Ñ7€Mõ Ô" :°Ò#3µe´h¸yÔ?PÐRSÑ6TÔ6TÐ5TÑUÔU€JØÕ-µ´Ø�%œ-°
Ô0Að1ñ 1ô 1ñ ñ €Mð (ð 
ØÕ1µE´OÝŒH�YÔ&¨Ñ*Ô*µ%´-È	ÔHYÔH`ð5
ñ 5
ô 5
ñ 
ñ 	
ˆð Ðr,   c           	      óH  — t          t          j        |t          j        |j        ¬¦  «        |¦  «        \  }}t          j        |d¬¦  «        }t          j        t          j        |d¬¦  «        d         d¦  «        }	t          j        |	 	                    | 
                    ¦   «         ¦  «        t          j        |¦  «        |¦  «        }t          j                             |¬¦  «        }
|
                     |¦  «         }t          | |¦  «        \  }}t!          t          j        |t          j        |j        ¬¦  «        |¦  «        \  }}|                     |¦  «        j        }t          j        t          j        |t          j        |d¬¦  «        ¦  «        t          j        |j        ¬¦  «        }t          j                             |¬¦  «        }|                     |                     t          j        ¦  «        ¦  «        }t          j        ||z  |z  d¬¦  «         }|t          j        ||z  d¬¦  «        t0          z   z  }|}|t          j        |	 	                    | 
                    ¦   «         ¦  «        t          j        |¦  «        |¦  «        z  }t          j        t          j        |d¬¦  «        t          j        |j        ¬¦  «        }t          j        t          j        |t          j        |d¬¦  «        ¦  «        t          j        |j        ¬¦  «        }t          j        t          j        |d¦  «         	                    | 
                    ¦   «         ¦  «        t          j        |¦  «        |¦  «        }|t2          d||z  z
  z  z   }t5          ||¦  «        }||fS )aª  
    Computes the loss for cell selection constrained to a single column. The loss is a hierarchical log-likelihood. The
    model first predicts a column and then selects cells within that column (conditioned on the column). Cells outside
    the selected column are never selected.

    Args:
        token_logits (`torch.FloatTensor` of shape `(batch_size, sequence_length)`):
            Tensor containing the logits per token.
        column_logits (`torch.FloatTensor` of shape `(batch_size, max_num_cols)`):
            Tensor containing the logits per column.
        labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
            Labels per token.
        cell_index (`ProductIndexMap`):
            Index that groups tokens into cells.
        col_index (`IndexMap`):
            Index that groups tokens into columns.
        cell_mask (`torch.FloatTensor` of shape `(batch_size, max_num_rows * max_num_cols)`):
            Mask for cells that exist in the table (i.e. that are not padding).

    Returns:
        selection_loss_per_example (`torch.FloatTensor` of shape `(batch_size,)`): Loss for each example. logits
        (`torch.FloatTensor` of shape `(batch_size, sequence_length)`): New logits which are only allowed to select
        cells in a single column. Logits outside of the most likely column according to *column_logits* will be set to
        a very low value (such that the probabilities are 0).
    rO   rN   rˆ   r   rh  r   rj  )rï  r'   r`   r  rQ   Úargmaxrÿ  Úmaxrn  r‹   rU   rp  r}  ÚCategoricalr�  rs  rõ  rW   rÀ  rf  rX   r~  r¼  r‚  rƒ  r   r^   )r  r�  rL  r‹  rj   rŽ  Úlabels_per_columnr�  Úcolumn_labelÚno_cell_selectedÚcolumn_distÚcolumn_loss_per_exampler•  Úlabels_per_cellÚlabels_indexÚcolumn_id_for_cellsÚcolumn_maskÚ	cell_distÚcell_log_probÚ	cell_lossr—  Úselected_column_idÚselected_column_maskÚnew_logits_per_cellr   s                            r-   r„  r„  r  sY  € õ: &¥e¤o°fÅEÄMÐZ`ÔZgÐ&hÑ&hÔ&hÐjsÑtÔtÑÐ�qå”<Ð 1°rÐ:Ñ:Ô:€Lõ ”xÝŒ	Ð#¨Ð,Ñ,Ô,¨QÔ/°ñô Ðõ ”;Ø×Ò˜l×/Ò/Ñ1Ô1Ñ2Ô2µEÔ4DÀ\Ñ4RÔ4RÐT`ñô €Lõ Ô%×1Ò1¸Ð1ÑGÔG€KØ*×3Ò3°LÑAÔAÐAÐõ % \°:Ñ>Ô>Ñ€O�Qå$.ÝŒ˜¥e¤j¸¼ÐGÑGÔGÈñ%ô %Ñ!€O�\ð %×2Ò2°<Ñ@Ô@ÔHÐå”/ÝŒÐ$¥e¤o°lÈÐ&KÑ&KÔ&KÑLÔLÝŒmØÔðñ ô €Kõ Ô#×-Ò-°_Ð-ÑEÔE€IØ×&Ò& ×';Ò';½E¼MÑ'JÔ'JÑKÔK€Må”˜=¨;Ñ6¸ÑBÈÐJÑJÔJÐJ€Ið •”˜;¨Ñ2¸Ð:Ñ:Ô:Õ=RÑRÑR€Ià!8ÐØ¥%¤+Ø×ÒÐ8×=Ò=Ñ?Ô?Ñ@Ô@ÝÔÐ3Ñ4Ô4Øñ#ô #ñ Ðõ œÝŒ�]¨Ð+Ñ+Ô+µ5´:ÀmÔFZðñ ô Ðõ
 !œ?ÝŒÐ$¥e¤oÐ6HÈbÐ&QÑ&QÔ&QÑRÔRÝŒmØ!Ô(ðñ ô Ðõ !œ;ÝŒÐ$ aÑ(Ô(×-Ò-Ð.B×.GÒ.GÑ.IÔ.IÑJÔJÝÔÐ-Ñ.Ô.Øñô Ðð
 *Õ,DÈÈiÐZnÑNnÑHnÑ,oÑoÐÝÐ'¨Ñ4Ô4€Fà% vÐ-Ð-r,   c                 ó>   — t          j        d| |¦  «        |z   |z  }|S )aÃ  
    Computes logits per token

    Args:
        sequence_output (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`):
            Also known as last_hidden_state. Sequence of hidden-states at the output of the last layer of the model.
        temperature (`float`):
            Temperature for the Bernoulli distribution.
        output_weights (`torch.FloatTensor` of shape `(hidden_size,)`):
            Weights of the linear layer for cell selection.
        output_bias (`torch.FloatTensor` of shape `()`):
            Bias of the linear layer for cell selection

    Returns:
        logits (`torch.FloatTensor` of shape `(batch_size, sequence_length)`): Logits per token.
    rû  )r'   rý  )r  ru  r%  r)  r   s        r-   rt  rt  Ý  s'   € õ" Œl˜;¨¸ÑHÔHÈ;ÑVÐZeÑe€Fà€Mr,   c                 óª  — t          j        t          j        | ¦  «        ¦  «                             t           j        ¦  «                             | j        ¦  «        } ||¦  «        }t           j        j         	                    |¬¦  «        }t          j
        |j        dd…dd…f         d¬¦  «        }||k    }	t          j
        |d¬¦  «        dk    }
t          j        t          j        |	|
¦  «                             |                     ¦   «         ¦  «        t          j        |t           j        ¬¦  «        |¦  «        }|                     ¦   «         }|S )aÊ  
    Finds examples where the model should select cells with no aggregation.

    Returns a mask that determines for which examples should the model select answers directly from the table, without
    any aggregation function. If the answer is a piece of text the case is unambiguous as aggregation functions only
    apply to numbers. If the answer is a number but does not appear in the table then we must use some aggregation
    case. The ambiguous case is when the answer is a number that also appears in the table. In this case we use the
    aggregation function probabilities predicted by the model to decide whether to select or aggregate. The threshold
    for this is a hyperparameter *cell_selection_preference*

    Args:
        answer (`torch.FloatTensor` of shape `(batch_size, )`):
            Answer for every example in the batch. Nan if there is no scalar answer.
        pooled_output (`torch.FloatTensor` of shape `(batch_size, hidden_size)`):
            Output of the pooler (BertPooler) on top of the encoder layer.
        cell_selection_preference (`float`):
            Preference for cell selection in ambiguous cases.
        labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
            Labels per token. aggregation_classifier (`torch.nn.Linear`): Aggregation head

    Returns:
        aggregate_mask (`torch.FloatTensor` of shape `(batch_size,)`): A mask set to 1 for examples that should use
        aggregation functions.
    rh  Nr   rˆ   r   ri  )r'   Úlogical_notÚisnanr¼  r(   rq  rQ   r}  Úcategoricalr  r‚  Úprobsrn  rþ  r‹   rU   rp  r  Údetach)Úanswerr  r{  rL  rV  Úaggregate_mask_initr    Údist_aggregationÚaggregation_ops_total_massÚis_pred_cell_selectionÚis_cell_supervision_availabler”  s               r-   rz  rz  ó  s5  € õ4  Ô+­E¬K¸Ñ,?Ô,?Ñ@Ô@×EÒEÅeÔFWÑXÔX×[Ò[Ð\bÔ\iÑjÔjÐØ/Ð/°Ñ>Ô>ÐÝÔ*Ô6×BÒBÐJ\ÐBÑ]Ô]Ðå!&¤Ð+;Ô+AÀ!À!À!ÀQÀRÀRÀ%Ô+HÈaÐ!PÑ!PÔ!PÐð 8Ð;TÒTÐõ %*¤I¨f¸!Ð$<Ñ$<Ô$<¸qÒ$@Ð!å”[ÝÔÐ0Ð2OÑPÔP×UÒUÐVi×VnÒVnÑVpÔVpÑqÔqÝÔÐ,µE´MÐBÑBÔBØñô €Nð $×*Ò*Ñ,Ô,€NàÐr,   c                 óV  — |r!t          j        |t           j        ¬¦  «        }n|}t          j                             ||¬¦  «                             t           j        ¦  «        }t          j                             | d¬¦  «        }t          j	        ||z  d¬¦  «         }|r|d|z
  z  S |S )a  
    Calculates aggregation loss when its type is known during training.

    In the weakly supervised setting, the only known information is that for cell selection examples, "no aggregation"
    should be predicted. For other examples (those that require aggregation), no loss is accumulated. In the setting
    where aggregation type is always known, standard cross entropy loss is accumulated for all examples

    Args:
        logits_aggregation (`torch.FloatTensor` of shape `(batch_size, num_aggregation_labels)`):
            Logits per aggregation operation.
        aggregate_mask (`torch.FloatTensor` of shape `(batch_size, )`):
            A mask set to 1 for examples that should use aggregation functions.
        aggregation_labels (`torch.LongTensor` of shape `(batch_size, )`):
            Aggregation function id for every example in the batch.
        use_answer_as_supervision (`bool`, *optional*):
            Whether to use the answer as the only supervision for aggregation examples.
        num_aggregation_labels (`int`, *optional*, defaults to 0):
            The number of aggregation operators to predict.

    Returns:
        aggregation_loss_known (`torch.FloatTensor` of shape `(batch_size,)`): Aggregation loss (when its type is known
        during training) per example.
    ri  )Únum_classesrN   rˆ   r   )
r'   rp  rW   r   r™   Úone_hotr¼  r  Úlog_softmaxr‚  )	r    r”  rX  ry  rU  Útarget_aggregationÚone_hot_labelsÚ	log_probsÚ$per_example_aggregation_intermediates	            r-   Ú!_calculate_aggregation_loss_knownr0  $  s¸   € ð4 !ð 0å"Ô-¨nÅEÄJÐOÑOÔOÐÐð 0Ðå”]×*Ò*Ð+=ÐKaÐ*ÑbÔb×gÒgÕhmÔhuÑvÔv€NÝ”×)Ò)Ð*<À"Ð)ÑEÔE€Iõ -2¬I°nÀyÑ6PÐVXÐ,YÑ,YÔ,YÐ+YÐ(Ø ð 4ð 4°q¸>Ñ7IÑJÐJà3Ð3r,   c                 óÊ   — t           j        j                             | ¬¦  «        }t          j        |j        dd…dd…f         d¬¦  «        }t          j        |¦  «         |z  S )a  
    Calculates aggregation loss in the case of answer supervision.

    Args:
        logits_aggregation (`torch.FloatTensor` of shape `(batch_size, num_aggregation_labels)`):
            Logits per aggregation operation.
        aggregate_mask (`torch.FloatTensor` of shape `(batch_size, )`):
            A mask set to 1 for examples that should use aggregation functions

    Returns:
        aggregation_loss_unknown (`torch.FloatTensor` of shape `(batch_size,)`): Aggregation loss (in case of answer
        supervision) per example.
    rh  Nr   rˆ   )r'   r}  r  r  r‚  r   Úlog)r    r”  r$  r%  s       r-   Ú#_calculate_aggregation_loss_unknownr3  R  sg   € õ Ô*Ô6×BÒBÐJ\ÐBÑ]Ô]Ðå!&¤Ð+;Ô+AÀ!À!À!ÀQÀRÀRÀ%Ô+HÈaÐ!PÑ!PÔ!PÐõ
 ŒIÐ0Ñ1Ô1Ð1°NÑBÐBr,   c                 ó\   — t          | ||||¦  «        }|r|t          | |¦  «        z  }||z  S )aü  
    Calculates the aggregation loss per example.

    Args:
        logits_aggregation (`torch.FloatTensor` of shape `(batch_size, num_aggregation_labels)`):
            Logits per aggregation operation.
        aggregate_mask (`torch.FloatTensor` of shape `(batch_size, )`):
            A mask set to 1 for examples that should use aggregation functions.
        aggregation_labels (`torch.LongTensor` of shape `(batch_size, )`):
            Aggregation function id for every example in the batch.
        use_answer_as_supervision (`bool`, *optional*):
            Whether to use the answer as the only supervision for aggregation examples.
        num_aggregation_labels (`int`, *optional*, defaults to 0):
            The number of aggregation operators to predict.
        aggregation_loss_weight (`float`, *optional*, defaults to 1.0):
            Importance weight for the aggregation loss.

    Returns:
        aggregation_loss (`torch.FloatTensor` of shape `(batch_size,)`): Aggregation loss per example.
    )r0  r3  )r    r”  rX  ry  rU  rˆ  Úper_example_aggregation_losss          r-   r‡  r‡  j  sR   € õ8 $EØ˜NÐ,>Ð@YÐ[qñ$ô $Ð ð !ð pà$Õ(KÐL^Ð`nÑ(oÔ(oÑoÐ$Ø"Ð%AÑAÐAr,   c                 ó”  — |j         rHt          j                             |j        | j        |j        z  ¬¦  «        }|                     ¦   «         }n| j        }||z  |z  }t          j        |d¬¦  «        }t          j	        t          j
        |¦  «        t          j        |¦  «        |¦  «        }	t          j        ||	z  d¬¦  «        }
|j        }|t          j        k    r|
|t          z   z  }nê|t          j        k    r:t          j        |dd¬¦  «        |z
  dz   }t          j        |	|z  |z  d¬¦  «        }n |t          j        k    ryt          j        |dd¬¦  «        |z
  dz   }|d|z
  z  }t          j        |dd¬¦  «        |z
  }|t          j        |¦  «        z  dz   |z  }t          j        |	|z  |z  d¬¦  «        }nt'          d|j        › �¦  «        ‚|j        rGt          j                             |j        |dd…dd…f         ¬¦  «        }|                     ¦   «         }n5t.          j                             |dd…dd…f         |j        z  d	¬¦  «        }t          j        t          j        |
d¬¦  «        t          j        |d¬¦  «        t          j        |d¬¦  «        gd¬¦  «        }t          j        ||z  d¬¦  «        }|S )
a  
    Calculates the expected result given cell and aggregation probabilities.

    Args:
        dist_per_cell (`torch.distributions.Bernoulli`):
            Cell selection distribution for each cell.
        numeric_values (`torch.FloatTensor` of shape `(batch_size, seq_length)`):
            Numeric values of every token. Nan for tokens which are not numeric values.
        numeric_values_scale (`torch.FloatTensor` of shape `(batch_size, seq_length)`):
            Scale of the numeric values of every token.
        input_mask_float (`torch.FloatTensor` of shape `(batch_size, seq_length)`):
            Mask for the table, without question tokens and table headers.
        logits_aggregation (`torch.FloatTensor` of shape `(batch_size, num_aggregation_labels)`):
            Logits per aggregation operation.
        config ([`TapasConfig`]):
            Model configuration class with all the hyperparameters of the model

    Returns:
        expected_result (`torch.FloatTensor` of shape `(batch_size,)`): The expected result per example.
    )ru  r   r   rˆ   T)r‰   Úkeepdimz(Invalid average_approximation_function: Nrh  rN   )Úuse_gumbel_for_cellsr'   r}  ÚRelaxedBernoulliru  r   Úsampler   r‚  rn  r  rp  Úaverage_approximation_functionr©  r­  rƒ  r®  r¯  Úsquarerz   Úuse_gumbel_for_aggregationÚRelaxedOneHotCategoricalÚaggregation_temperaturer   r™   rš   rÔ  rX   )Údist_per_cellrZ  r[  rŒ  r    rH   Úgumbel_distÚscaled_probability_per_cellÚcount_resultÚnumeric_values_maskedÚ
sum_resultÚavg_approximationÚaverage_resultÚexÚpointwise_varÚvarÚ
multiplierÚaggregation_op_only_probsÚall_resultsÚexpected_results                       r-   Ú_calculate_expected_resultrO  �  s#  € ð. Ô"ð 	:ÝÔ)×:Ò:ð Ô*Ø Ô'¨&Ô*<Ñ<ð	 ;ñ 
ô 
ˆð '2×&8Ò&8Ñ&:Ô&:Ð#Ð#à&3Ô&9Ð#ð $?ÐAUÑ#UÐYiÑ"iÐÝ”9Ð8¸aÐ@Ñ@Ô@€LÝ!œKÝŒ�NÑ#Ô#¥UÔ%5°nÑ%EÔ%EÀ~ñô Ðõ ”Ð6Ð9NÑNÐTUÐVÑVÔV€JØÔ=ÐØÕ8Ô>Ò>Ð>Ø# |Õ6KÑ'KÑLˆˆØ	Õ:ÔFÒ	FÐ	Fõ
 ŒYÐ2¸À4ÐHÑHÔHÐKfÑfÐijÑjˆÝœÐ#8Ð;VÑ#VÐY[Ñ#[ÐabÐcÑcÔcˆˆØ	Õ:ÔGÒ	GÐ	GåŒYÐ2¸À4ÐHÑHÔHÐKfÑfÐijÑjˆØ3°qÐ;VÑ7VÑWˆÝŒi˜¨1°dÐ;Ñ;Ô;¸mÑKˆà�EœL¨Ñ,Ô,Ñ,¨qÑ0°BÑ6ˆ
ÝœÐ#8Ð;VÑ#VÐYcÑ#cÐijÐkÑkÔkˆˆåÐkÀFÔDiÐkÐkÑlÔlÐlàÔ(ð 

ÝÔ)×BÒBØÔ*Ð3EÀaÀaÀaÈÈÈÀeÔ3Lð Cñ 
ô 
ˆð %0×$6Ò$6Ñ$8Ô$8Ð!Ð!õ %'¤M×$9Ò$9Ø˜q˜q˜q ! " "˜uÔ%¨Ô(FÑFÈBð %:ñ %
ô %
Ð!õ ”)åŒO˜J¨AÐ.Ñ.Ô.ÝŒO˜N°Ð2Ñ2Ô2ÝŒO˜L¨aÐ0Ñ0Ô0ð	
ð
 ðñ ô €Kõ ”i Ð.GÑ GÈQÐOÑOÔO€OØÐr,   rj  Údeltac                 óˆ   — t          j        | |z
  ¦  «        }t          j        ||k     d|dz  z  ||z  d|dz  z  z
  ¦  «        S )Nrü  rS   )r'   Úabsrn  )ÚinputÚtargetrP  Úerrorss       r-   Ú
huber_lossrV  è  sI   € ÝŒY�u˜v‘~Ñ&Ô&€FÝŒ;�v ’~ s¨V°Q©Y¡¸À¹È#ÐPUÐWXÑPXÉ.Ñ8YÑZÔZÐZr,   c                 óö  — t          ||||||¦  «        }t          j        t          j        | ¦  «        t          j        | ¦  «        | ¦  «        }	|j        rtt          j        t          j        |¦  «        t          j        |	¦  «        ¦  «        t          z    	                    ¦   «         }
|	|
z  }||
z  }t          ||z  ||z  ¦  «        }nt          ||z  |	|z  |j        ¬¦  «        }|j        €!t          j        |t          j        ¬¦  «        }n[t          j        ||j        k    t          j        |t          j        ¬¦  «        t          j        |t          j        ¬¦  «        ¦  «        }|j        ||z  z  }||fS )a  
    Calculates the regression loss per example.

    Args:
        answer (`torch.FloatTensor` of shape `(batch_size,)`):
            Answer for every example in the batch. Nan if there is no scalar answer.
        aggregate_mask (`torch.FloatTensor` of shape `(batch_size,)`):
            A mask set to 1 for examples that should use aggregation functions.
        dist_per_cell (`torch.distributions.Bernoulli`):
            Cell selection distribution for each cell.
        numeric_values (`torch.FloatTensor` of shape `(batch_size, seq_length)`):
            Numeric values of every token. Nan for tokens which are not numeric values.
        numeric_values_scale (`torch.FloatTensor` of shape `(batch_size, seq_length)`):
            Scale of the numeric values of every token.
        input_mask_float (`torch.FloatTensor` of shape `(batch_size, seq_length)`):
            Mask for the table, without question tokens and table headers.
        logits_aggregation (`torch.FloatTensor` of shape `(batch_size, num_aggregation_labels)`):
            Logits per aggregation operation.
        config ([`TapasConfig`]):
            Model configuration class with all the parameters of the model

    Returns:
        per_example_answer_loss_scaled (`torch.FloatTensor` of shape `(batch_size,)`): Scales answer loss for each
        example in the batch. large_answer_loss_mask (`torch.FloatTensor` of shape `(batch_size,)`): A mask which is 1
        for examples for which their answer loss is larger than the answer_loss_cutoff.
    )rP  Nri  )rO  r'   rn  r  rp  Úuse_normalized_answer_lossr
  rR  rƒ  r!  rV  Úhuber_loss_deltaÚanswer_loss_cutoffro  r  Úanswer_loss_importance)r"  r”  r@  rZ  r[  rŒ  r    rH   rN  Úanswer_maskedÚ
normalizerÚnormalized_answer_maskedÚnormalized_expected_resultÚper_example_answer_lossrœ  Úper_example_answer_loss_scaleds                   r-   r‰  r‰  í  sŒ  € õJ 1Ø�~Ð';Ð=MÐOaÐciñô €Oõ
 ”K¥¤¨FÑ 3Ô 3µUÔ5EÀfÑ5MÔ5MÈvÑVÔV€MàÔ(ð 
Ý”i¥¤	¨/Ñ :Ô :½E¼IÀmÑ<TÔ<TÑUÔUÕXmÑm×uÒuÑwÔwˆ
à#0°:Ñ#=Ð Ø%4°zÑ%AÐ"Ý",Ø&¨Ñ7Ð9QÐTbÑ9bñ#
ô #
ÐÐõ #-Ø˜nÑ,¨m¸nÑ.LÐTZÔTkð#
ñ #
ô #
Ðð Ô Ð(Ý!&¤Ð1HÕPUÔP]Ð!^Ñ!^Ô!^ÐÐõ "'¤Ø# fÔ&?Ò?ÝÔÐ4½E¼MÐJÑJÔJÝŒOÐ3½5¼=ÐIÑIÔIñ"
ô "
Ðð
 &,Ô%BÐF]Ð`nÑFnÑ%oÐ"à)Ð+AÐAÐAr,   )rD  r#  rž  r0  r  )rÁ  )rÃ  )rÎ  )rë  )rð  )rò  )r÷  )rj  )Xr&   Úenumr—   Údataclassesr   r'   r   Útorch.nnr   r   r   Ú r	   r!  Úactivationsr
   Úcache_utilsr   r   r   Úmasking_utilsr   Úmodeling_layersr   Úmodeling_outputsr   r   r   r   Úmodeling_utilsr   Úpytorch_utilsr   Úutilsr   r   r   Úconfiguration_tapasr   Ú
get_loggerr#   Úloggerrƒ  r   r   ÚModuler/   ru   r²   rÁ   rË   rÔ   rØ   ré   rÿ   r  r  r  r  r0  rD  r#  rž  rÏ   ÚEnumr©  r[   r\   r^   rÍ  rÎ  rê  rï  rs  rõ  r]   rw  r„  rt  rz  r0  r3  r‡  rO  rr  rV  r‰  Ú__all__r+   r,   r-   ú<module>rt     sW  ðð Ð à €€€Ø €€€Ø !Ð !Ð !Ð !Ð !Ð !à €€€Ø Ð Ð Ð Ð Ð Ø AÐ AÐ AÐ AÐ AÐ AÐ AÐ AÐ AÐ Aà &Ð &Ð &Ð &Ð &Ð &Ø !Ð !Ð !Ð !Ð !Ð !Ø CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CØ 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø uÐ uÐ uÐ uÐ uÐ uÐ uÐ uÐ uÐ uÐ uÐ uØ -Ð -Ð -Ð -Ð -Ð -Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,ð 
ˆÔ	˜HÑ	%Ô	%€ð Ð Ø#Ð ð €ððñ ô ð
 ð7ð 7ð 7ð 7ð 7 ;ñ 7ô 7ñ „ñô ð7ð$Jð Jð Jð Jð J�b”iñ Jô Jð JðZVð Vð Vð Vð V˜œñ Vô Vð Vðtð ð ð ð �b”iñ ô ð ðð ð ð ð �R”Yñ ô ð ð:ð ð ð ð ˜œ	ñ ô ð ð ð ð ð ð �"”)ñ ô ð ð?ð ?ð ?ð ?ð ?Ð+ñ ?ô ?ð ?ðD0
ð 0
ð 0
ð 0
ð 0
�2”9ñ 0
ô 0
ð 0
ðhð ð ð ð �"”)ñ ô ð ð ð ð ð ð  2¤9ñ ô ð ð$ð ð ð ð ˜BœIñ ô ð ð"!ð !ð !ð !ð !�r”yñ !ô !ð !ð ð3ð 3ð 3ð 3ð 3˜?ñ 3ô 3ñ „ð3ð, ðR
ð R
ð R
ð R
ð R
Ð%ñ R
ô R
ñ „ðR
ðj ðs
ð s
ð s
ð s
ð s
Ð+ñ s
ô s
ñ „ðs
ðl €ððñ ô ðI
ð I
ð I
ð I
ð I
Ð 4ñ I
ô I
ñô ðI
ðX
 €ððñ ô ðy
ð y
ð y
ð y
ð y
Ð%9ñ y
ô y
ñô ðy
ðx ð"ð "ð "ð "ð " 3¨¬	ñ "ô "ð "ð6ð 6ð 6ð 6ð 6ñ 6ô 6ð 6ð4*
ð *
ð *
ð *
ð *
�hñ *
ô *
ð *
ðZ?ð ?ð ?ð ?ðBjð jð jð jð:)hð )hð )hð )hðX.'ð .'ð .'ðb7ð 7ð 7ð 7ð68ð 8ð 8ð 8ð:8ð 8ð 8ð 8ð68ð 8ð 8ð 8ð<1ð 1ð 1ðhh.ð h.ð h.ðVð ð ð,.ð .ð .ðb+4ð +4ð +4ð\Cð Cð Cð0#Bð #Bð #BðLTð Tð Tðp[ð [ Uð [ð [ð [ð [ð
DBð DBð DBðNð ð €€€r,   