
    gq                    >   d Z ddlZddlZddlmZmZmZ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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mZmZm Z  ddl!m"Z" ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z-  e*j.        e/          Z0dZ1dZ2 G d de	j3                  Z4 G d de	j3                  Z5 G d de	j3                  Z6 G d de	j3                  Z7 G d de	j3                  Z8 G d de	j3                  Z9 G d de	j3                  Z: G d  d!e	j3                  Z; G d" d#e	j3                  Z< G d$ d%e"          Z= G d& d'e=          Z>d(Z?d)Z@d*ZA e&d+e?           G d, d-e=                      ZB e&d.e?           G d/ d0e=e                      ZC e&d1e?           G d2 d3e=                      ZD e&d4e?           G d5 d6e=                      ZE e&d7e?           G d8 d9e=                      ZF e&d:e?           G d; d<e=                      ZGdS )=zPyTorch UMT5 model.    N)ListOptionalTupleUnion)nn)BCEWithLogitsLossCrossEntropyLossMSELoss   )ACT2FN)CacheDynamicCacheEncoderDecoderCacheStaticCache)GenerationMixin)AttentionMaskConverter)BaseModelOutput)BaseModelOutputWithPastAndCrossAttentionsSeq2SeqLMOutputSeq2SeqModelOutput#Seq2SeqQuestionAnsweringModelOutputSeq2SeqSequenceClassifierOutputTokenClassifierOutput)PreTrainedModel)DUMMY_INPUTS
DUMMY_MASKadd_start_docstrings%add_start_docstrings_to_model_forwardis_torch_fx_proxyis_torchdynamo_compilingloggingreplace_return_docstrings   )
UMT5Configr$   zgoogle/umt5-smallc                   &     e Zd Zd fd	Zd Z xZS )UMT5LayerNormư>c                     t                                                       t          j        t	          j        |                    | _        || _        dS )ze
        Construct a layernorm module in the UMT5 style. No bias and no subtraction of mean.
        N)super__init__r   	Parametertorchonesweightvariance_epsilon)selfhidden_sizeeps	__class__s      b/var/www/html/ai-engine/env/lib/python3.11/site-packages/transformers/models/umt5/modeling_umt5.pyr*   zUMT5LayerNorm.__init__<   sD     	l5:k#:#:;; #    c                 h   |                     t          j                                      d                              dd          }|t          j        || j        z             z  }| j        j        t          j	        t          j
        fv r|                     | j        j                  }| j        |z  S )N   T)keepdim)tor,   float32powmeanrsqrtr/   r.   dtypefloat16bfloat16)r0   hidden_statesvariances      r4   forwardzUMT5LayerNorm.forwardD   s     !##EM2266q99>>r4>PP%Ht?T4T(U(UU ; ???),,T[->??M{]**r5   )r'   )__name__
__module____qualname__r*   rD   __classcell__r3   s   @r4   r&   r&   ;   sL        $ $ $ $ $ $+ + + + + + +r5   r&   c                   *     e Zd Zdef fdZd Z xZS )UMT5DenseActDenseconfigc                 J   t                                                       t          j        |j        |j        d          | _        t          j        |j        |j        d          | _        t          j        |j	                  | _
        t          |j                 | _        d S NFbias)r)   r*   r   Lineard_modeld_ffwiwoDropoutdropout_ratedropoutr   dense_act_fnactr0   rL   r3   s     r4   r*   zUMT5DenseActDense.__init__V   sx    )FNFKeDDD)FKeDDDz&"566&-.r5   c                    |                      |          }|                     |          }|                     |          }t          | j        j        t          j                  r]|j        | j        j        j        k    rC| j        j        j        t          j	        k    r$|
                    | j        j        j                  }|                     |          }|S N)rT   rZ   rX   
isinstancerU   r.   r,   Tensorr?   int8r:   r0   rB   s     r4   rD   zUMT5DenseActDense.forward]   s    ..//]33tw~u|44	C#tw~';;;$
22),,TW^-ABBM..r5   rE   rF   rG   r$   r*   rD   rH   rI   s   @r4   rK   rK   U   sS        /z / / / / / /      r5   rK   c                   *     e Zd Zdef fdZd Z xZS )UMT5DenseGatedActDenserL   c                    t                                                       t          j        |j        |j        d          | _        t          j        |j        |j        d          | _        t          j        |j        |j        d          | _        t          j	        |j
                  | _        t          |j                 | _        d S rN   )r)   r*   r   rQ   rR   rS   wi_0wi_1rU   rV   rW   rX   r   rY   rZ   r[   s     r4   r*   zUMT5DenseGatedActDense.__init__m   s    IfnfkFFF	IfnfkFFF	)FKeDDDz&"566&-.r5   c                    |                      |                     |                    }|                     |          }||z  }|                     |          }t	          | j        j        t          j                  r]|j	        | j        j        j	        k    rC| j        j        j	        t          j
        k    r$|                    | j        j        j	                  }|                     |          }|S r]   )rZ   rf   rg   rX   r^   rU   r.   r,   r_   r?   r`   r:   )r0   rB   hidden_geluhidden_linears       r4   rD   zUMT5DenseGatedActDense.forwardu   s    hhtyy7788		-00#m3]33 tw~u|44	C#tw~';;;$
22),,TW^-ABBM..r5   rb   rI   s   @r4   rd   rd   l   sS        /z / / / / / /      r5   rd   c                   *     e Zd Zdef fdZd Z xZS )UMT5LayerFFrL   c                 $   t                                                       |j        rt          |          | _        nt          |          | _        t          |j        |j                  | _	        t          j        |j                  | _        d S )Nr2   )r)   r*   is_gated_actrd   DenseReluDenserK   r&   rR   layer_norm_epsilon
layer_normr   rV   rW   rX   r[   s     r4   r*   zUMT5LayerFF.__init__   sx     	<"8"@"@D"3F";";D'F<UVVVz&"566r5   c                     |                      |          }|                     |          }||                     |          z   }|S r]   )rr   rp   rX   )r0   rB   forwarded_statess      r4   rD   zUMT5LayerFF.forward   sF    ??=99../?@@%5E(F(FFr5   rb   rI   s   @r4   rl   rl      sS        7z 7 7 7 7 7 7      r5   rl   c                       e Zd ZdZddee         f fdZdej        dej        fdZ	d	 Z
dd
Z	 	 	 	 	 ddej        deej                 deeej                          deej                 deej                 deej                 fdZ xZS )UMT5Attentionz7
    T5's attention using relative_attention_bias.
    FN	layer_idxc                 B   t                                                       |j        | _        || _        |j        | _        |j        | _        |j        | _        |j        | _        |j	        | _
        |j        | _        | j
        | j        z  | _        || _        |/| j        r(t                              d| j        j         d           t'          j        | j        | j        d          | _        t'          j        | j        | j        d          | _        t'          j        | j        | j        d          | _        t'          j        | j        | j        d          | _        | j        r$t'          j        | j        | j
                  | _        t7                      | _        d S )NzInstantiating a decoder z without passing `layer_idx` is not recommended and will to errors during the forward call, if caching is used. Please make sure to provide a `layer_idx` when creating this class.FrO   )r)   r*   
is_decoderhas_relative_attention_biasrelative_attention_num_bucketsrelative_attention_max_distancerR   d_kvkey_value_proj_dim	num_headsn_headsrW   rX   	inner_dimrw   loggerwarning_oncer3   rE   r   rQ   qkvo	Embeddingrelative_attention_biassetpruned_heads)r0   rL   rz   rw   r3   s       r4   r*   zUMT5Attention.__init__   sk    ++F(.4.S+/5/U,~"(+'*(??",4>+B , , ,   4<eDDD4<eDDD4<eDDD4>4<eDDD+ 	k+-<8[]a]i+j+jD(EEr5   
projectionreturnc                     |                                 d d         | j        | j        fz   }|                    |                              dddd          }|S )Nr8   r   r7   r#   r   )sizer   r~   viewpermute)r0   r   new_projection_shapenew_projections       r4   _shapezUMT5Attention._shape   sW    )00"5tG^8__#)=>>FFq!QPQRRr5   c                 ~   d}| j         }| j        }| j        sC|dz  }||dk                        t          j                  |z  z  }t	          j        |          }n(t	          j        |t	          j        |                     }|dz  }||k     }t	          j	        |
                                |z            t          j	        ||z            z  }|||z
  z  }||                    t          j                  z   }t	          j        |t	          j        ||dz
                      }|t	          j        |||          z  }|S )a  
        Adapted from Mesh Tensorflow:
        https://github.com/tensorflow/mesh/blob/0cb87fe07da627bf0b7e60475d59f95ed6b5be3d/mesh_tensorflow/transformer/transformer_layers.py#L593

        Translate relative position to a bucket number for relative attention. The relative position is defined as
        memory_position - query_position, i.e. the distance in tokens from the attending position to the attended-to
        position. If bidirectional=False, then positive relative positions are invalid. We use smaller buckets for
        small absolute relative_position and larger buckets for larger absolute relative_positions. All relative
        positions >=max_distance map to the same bucket. All relative positions <=-max_distance map to the same bucket.
        This should allow for more graceful generalization to longer sequences than the model has been trained on

        Args:
            relative_position: an int32 Tensor
            bidirectional: a boolean - whether the attention is bidirectional
            num_buckets: an integer
            max_distance: an integer

        Returns:
            a Tensor with the same shape as relative_position, containing int32 values in the range [0, num_buckets)
        r   r7   r#   )r{   r|   ry   r:   r,   longabsmin
zeros_likelogfloatmath	full_likewhere)	r0   relative_positionrelative_bucketsnum_bucketsmax_distance	max_exactis_small	log_ratiorelative_position_if_larges	            r4   _relative_position_bucketz'UMT5Attention._relative_position_bucket   sP   * 9; 	cAK!2Q!6 : :5: F F TT %	*; < <!&+<e>NO`>a>a!b!b b  1$	$y0 I/5577)CDDtxP\_hPhGiGii	y!89	%.ej1I1I%I"%*Y&8RT_bcTc(d(d&
 &
" 	EK2CE_```r5   c                    || j         j        j        }|,t          j        |t          j        |          dddf         }n|dddf         }t          j        |t          j        |          dddf         }||z
  }|                     |          }|                      |          }	|	                    g d                              d          }	|	S )z%Compute binned relative position biasN)r?   device)r7   r   r#   r   )	r   r.   r   r,   aranger   r   r   	unsqueeze)
r0   query_length
key_lengthr   cache_positioncontext_positionmemory_positionr   relative_position_bucketvaluess
             r4   compute_biaszUMT5Attention.compute_bias   s    >18?F!$|L
SYZZZ[\[\[\^b[bc-aaag6,zFSSSTXZ[Z[Z[T[\+.>>#'#A#ABS#T#T --.FGG			**44Q77r5   rB   encoder_hidden_statespast_key_valueattention_masklayer_head_maskr   c                 x   |j         d d         \  }}|d u}	|                     |          }
|
                    |d| j        | j                                      dd          }
|0|j                            | j                  }|	r|j	        }n|j
        }|	r|n|}|	r)|'|r%|j        | j                 }|j        | j                 }n|                     |          }|                     |          }|                    |d| j        | j                                      dd          }|                    |d| j        | j                                      dd          }|9|	s|nd }|                    ||| j        d|i          \  }}|	rd|j        | j        <   t!          j        |
|                    dd                    }|||                                z   n|}|j         d         }| j        s+t!          j        d| j        ||f|j        |j                  }n3|                     |||j        |	          }|d d d d | d d d f         }|$|d d d d d d d |j         d         f         }||z   }| j        rUt!          j        |j         d                   }d
|t5          | j                  <   |d d |                                f         }n|}||z  }t8          j                            |                                d                               |          }t8          j        !                    || j!        | j"                  }|||z  }t!          j        ||          }|                    dd          #                                }|                    ||d          }| $                    |          }|||fS )Nr7   r8   r#   r   Tr   )r   r?   )r   r   r   dim)ptraining)%shaper   r   r   r~   	transpose
is_updatedgetrw   cross_attention_cacheself_attention_cache	key_cachevalue_cacher   r   updater,   matmulget_seq_lengthrz   zerosr   r?   r   r   r-   listboolr   
functionalsoftmaxr   type_asrX   r   
contiguousr   )r0   rB   r   r   r   r   r   
batch_size
seq_lengthis_cross_attentionquery_statesr   curr_past_key_valuecurrent_states
key_statesvalue_statesscoresreal_seq_lengthr   position_biascausal_maskmaskposition_bias_maskedattn_weightsattn_outputs                            r4   rD   zUMT5Attention.forward  s    "/!4RaR!8
J 3$>vvm,,#((RtG^__iijkmnoo%'266t~FFJ! J&4&J##&4&I#2DW..- 	E."<"<,6t~FJ.:4>JLL//J66.11L#RtG^__iijkmnooJ',,ZT\4KbccmmnoqrssL)7I!St+>+E+Edn?OQ_>`, ,(
L & E@DN-dn= lJ,@,@A,F,FGG KYJd*~'D'D'F'FFFjt%b)
/ 	A!KDL*j9&-W]Wc  MM !--FMR` .  M *!!!QQQaaa*?@M%(AAAqqq2HJ4DR4H2H)HIK)K7M 	1:m1!455D,-Dd'(()#0DIIKK#@  #0 && },,V\\^^,DDLLVTT},,\T\TXTa,bb &'/9Ll<>>!++Aq11<<>>!&&z:rBBff[))L.88r5   )FN)NNNNNNN)rE   rF   rG   __doc__r   intr*   r,   r_   r   r   r   r   rD   rH   rI   s   @r4   rv   rv      s?        " "XVY] " " " " " ": %,    -  -  - ^   $ 9=8<152615Y9 Y9|Y9  (5Y9 !u|!45	Y9
 !.Y9 "%,/Y9 !.Y9 Y9 Y9 Y9 Y9 Y9 Y9 Y9r5   rv   c                   B     e Zd Zddee         f fdZ	 	 	 	 ddZ xZS )UMT5LayerSelfAttentionNrw   c                     t                                                       t          |d|          | _        t	          |j        |j                  | _        t          j	        |j
                  | _        d S )NTrz   rw   rn   )r)   r*   rv   SelfAttentionr&   rR   rq   rr   r   rV   rW   rX   r0   rL   rw   r3   s      r4   r*   zUMT5LayerSelfAttention.__init___  sb    *6t_hiii'F<UVVVz&"566r5   c                     |                      |          }|                     |||||          }||                     |d                   z   }|f|dd          z   }|S )Nr   r   r   r   r   r#   )rr   r   rX   )	r0   rB   r   r   r   r   normed_hidden_statesattention_outputoutputss	            r4   rD   zUMT5LayerSelfAttention.forwarde  sz      $}==-- )+)) . 
 
 &5Ea5H(I(II "%5abb%99r5   r]   )NNNNrE   rF   rG   r   r   r*   rD   rH   rI   s   @r4   r   r   ^  so        7 7(3- 7 7 7 7 7 7        r5   r   c                   D     e Zd Zddee         f fdZ	 	 	 	 	 ddZ xZS )UMT5LayerCrossAttentionNrw   c                     t                                                       t          |d|          | _        t	          |j        |j                  | _        t          j	        |j
                  | _        d S )NFr   rn   )r)   r*   rv   EncDecAttentionr&   rR   rq   rr   r   rV   rW   rX   r   s      r4   r*   z UMT5LayerCrossAttention.__init__{  sc    ,VQVbklll'F<UVVVz&"566r5   c                     |                      |          }|                     ||||||          }||                     |d                   z   }	|	f|dd          z   }
|
S )Nr   r   r   r   r   r   r#   )rr   r   rX   )r0   rB   r   r   r   r   r   r   r   layer_outputr   s              r4   rD   zUMT5LayerCrossAttention.forward  s|      $}==// "7)+)) 0 
 
 %t||4DQ4G'H'HH/$4QRR$88r5   r]   r   r   rI   s   @r4   r   r   z  sr        7 7(3- 7 7 7 7 7 7 #       r5   r   c                   L     e Zd Zddee         f fdZ	 	 	 	 	 	 	 	 	 ddZ xZS )	UMT5BlockNrw   c                    t                                                       |j        | _        t          j                    | _        | j                            t          ||                     | j        r)| j                            t          ||                     | j                            t          |                     d S )Nrw   )
r)   r*   ry   r   
ModuleListlayerappendr   r   rl   r   s      r4   r*   zUMT5Block.__init__  s     +]__

09MMMNNN? 	TJ5f	RRRSSS
+f--.....r5   Fc                     | j         d         |||||
          \  }}}|j        t          j        k    rst          j        |j                  j        }t          j        t          j        |                                          |dz
  |          }t          j	        || |          }d }| j
        o|d u}|r | j         d         ||||||
          \  }}}|j        t          j        k    rst          j        |j                  j        }t          j        t          j        |                                          |dz
  |          }t          j	        || |          } | j         d         |          }|j        t          j        k    rst          j        |j                  j        }t          j        t          j        |                                          |dz
  |          }t          j	        || |          }||f}|	r|||fz  }|S )Nr   r   i  )r   maxr#   r   r8   )r   r?   r,   r@   finfor   r   isinfanyclampry   )r0   rB   r   r   encoder_attention_maskr   cross_attn_layer_head_maskr   	use_cacheoutput_attentionsr   self_attn_weights	max_dtypeclamp_valuecross_attn_weightsdo_cross_attentionr   s                    r4   rD   zUMT5Block.forward  s)    <I4:a=)+))<
 <
 <
8(. %-//M$788<I+ek-&@&@&D&D&F&F	TXHXZcddK!KK<[YYYM "!_R1Fd1R 	^@M
1&;5 :--A A A=M-~ "em33!K(;<<@	#k%+m*D*D*H*H*J*JIX\L\^ghh %M|Q\ ] ] ] '
2}55 %-//M$788<I+ek-&@&@&D&D&F&F	TXHXZcddK!KK<[YYYM 

  	?)+=>>Gr5   r]   )	NNNNNNFFNr   rI   s   @r4   r   r     s~        / /(3- / / / / / / "##'> > > > > > > >r5   r   c                   L     e Zd ZdZdef fdZdej        dej        fdZ xZ	S )UMT5ClassificationHeadz-Head for sentence-level classification tasks.rL   c                    t                                                       t          j        |j        |j                  | _        t          j        |j                  | _        t          j        |j        |j	                  | _
        d S )N)r   )r)   r*   r   rQ   rR   denserV   classifier_dropoutrX   
num_labelsout_projr[   s     r4   r*   zUMT5ClassificationHead.__init__  sc    Yv~v~>>
zF$=>>>	&.&2CDDr5   rB   r   c                     |                      |          }|                     |          }t          j        |          }|                      |          }|                     |          }|S r]   )rX   r  r,   tanhr  ra   s     r4   rD   zUMT5ClassificationHead.forward  s[    ]33

=11
=11]33m44r5   )
rE   rF   rG   r   r$   r*   r,   r_   rD   rH   rI   s   @r4   r  r    sw        77Ez E E E E E EU\ el        r5   r  c                   T    e Zd ZdZeZdZdZdZdZ	dgZ
dgZed             Zd Zd Zd	S )
UMT5PreTrainedModelz
    An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
    models.
    transformerTr   rU   c                 v    t          j        t                    }t          j        t                    }|||d}|S )N)decoder_input_ids	input_idsdecoder_attention_mask)r,   tensorr   r   )r0   r  
input_maskdummy_inputss       r4   r  z UMT5PreTrainedModel.dummy_inputs  s=    L..	\*--
!*"&0
 

 r5   c                    | j         j        }t          |t                    r$|j        j                            |dz             d	S t          |t          t          t          t          f          r|j        j        j                            d|dz             t          |d          r5| j         j        s)|j        j        j                            d|dz             t          |d          r[|j        j        j                            d|| j         j        dz  z             |j        j        j                                         d	S d	S t          |t(                    r`t          |d          rN|j        j        j                            d|dz             |j        j        j                                         d	S d	S t          |t,                    r|j        j        j                            d|| j         j        dz  z             t          |j        d          r/|j        j        #|j        j        j                                         |j        j        j                            d|| j         j        dz  z             t          |j        d          r1|j        j        '|j        j        j                                         d	S d	S d	S t          |t2                    r|j        j        j                            d|| j         j        dz  z             t          |j        d          r/|j        j        #|j        j        j                                         |j        j        j                            d|| j         j        dz  z             t          |j        d          r1|j        j        '|j        j        j                                         d	S d	S d	S t          |t:                    rt|j        j        j                            d|| j         j        dz  z             t          |j        d          r/|j        j        #|j        j        j                                         |j        j        j                            d|| j         j        dz  z             t          |j        d          r/|j        j        #|j        j        j                                         |j        j        j                            d|| j         j        dz  z             t          |j        d          r1|j        j        '|j        j        j                                         d	S d	S d	S t          |t@                    r| j         j        }| j         j!        }| j         j"        }|j#        j        j                            d|||z  dz  z             |j$        j        j                            d||dz  z             |j%        j        j                            d||dz  z             |j&        j        j                            d|||z  dz  z             |j'        r0|j(        j        j                            d||dz  z             d	S d	S d	S )
zInitialize the weights      ?        )r=   stdlm_head
qa_outputs      
classifierrP   N))rL   initializer_factorr^   r&   r.   datafill_	UMT5ModelUMT5ForConditionalGenerationUMT5EncoderModelUMT5ForQuestionAnsweringsharednormal_hasattrtie_word_embeddingsr#  r$  rR   rP   zero_UMT5ForTokenClassificationr&  r  r  r  rK   rT   rU   rS   rd   rf   rg   rv   r}   r   r   r   r   r   rz   r   )r0   modulefactorrR   r~   r   s         r4   _init_weightsz!UMT5PreTrainedModel._init_weights  sY   /fm,, =	oM$$Vc\22222, (	
 
 ;	o M %--3FSL-IIIvy)) O$+2Q O%*22#2NNNv|,, 4!(-553Ft{ObgkNkDl5mmm!&+11333334 4  :;; *	ov|,, 4!(-553FSL5QQQ!&+11333334 4  677 &	oL$,,#6dkFY^bEb;c,dddv|V,, /1B1N!&,,...O"'//SfI\aeHe>f/gggv// 2FO4H4T$)//111112 24T4T 122 	o I!))s4;CV[_B_8`)aaavy&)) ,fin.H	#))+++I!))s4;CSX\B\8])^^^vy&)) ,fin.H	#))+++++, ,.H.H 677 	oK#++&T[EX]aDa:b+cccv{F++ .0@0L %++---K#++&T[EX]aDa:b+cccv{F++ .0@0L %++---I!))s4;CSX\B\8])^^^vy&)) ,fin.H	#))+++++, ,.H.H.. 	o k)G!%!1k+GHO ((cv'L^B^cgAg7h(iiiHO ((cv$7O(PPPHO ((cv$7O(PPPHO ((cv'L^B^cgAg7h(iii1 o.5:BBQW\chl[lQmBnnnnn	o 	oo or5   c                    | j         j        }| j         j        }|t          d          t	          |          rHt          j        |j        d d         dz   |          }t          j        ||dd df         gd          }nD|	                    |j                  }|dd df         
                                |ddd f<   ||d<   |t          d          |                    |d	k    |           |S )
Nzself.model.config.decoder_start_token_id has to be defined. In UMT5 it is usually set to the pad_token_id. See UMT5 docs for more information.r8   )r#   .r   r#   ).r   z1self.model.config.pad_token_id has to be defined.)rL   decoder_start_token_idpad_token_id
ValueErrorr   r,   fullr   cat	new_zerosclonemasked_fill_)r0   r  r9  r:  shifted_input_idss        r4   _shift_rightz UMT5PreTrainedModel._shift_rightR  s   !%!C{/!)6   Y'' 	? %
9?3B3+?$+FH^ _ _ %	+<iSbS>Q*RXZ [ [ [ ) 3 3IO D D)238)<)B)B)D)Dc122g&(>f%PQQQ&&'8D'@,OOO  r5   N)rE   rF   rG   r   r$   config_classbase_model_prefixsupports_gradient_checkpointing_supports_cache_class_supports_static_cache_no_split_modules_keep_in_fp32_modulespropertyr  r6  rB   r5   r4   r  r    s         
 L%&*# !$!F  X@o @o @oD! ! ! ! !r5   r  c                        e Zd Zd fd	Zd Zd Z	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdej        dej        dej        d	e	d
e
f
dZedej        dededej        dej        dej        defd            Z xZS )	UMT5StackNc                    t                                                     || _        j        | _        t	          j        fdt          j                  D                       | _        t          j
        j                  | _        t	          j        j                  | _        d| _        |                                  d S )Nc                 2    g | ]}t          |           S )r   )r   ).0irL   s     r4   
<listcomp>z&UMT5Stack.__init__.<locals>.<listcomp>s  s&    #e#e#eqIf$B$B$B#e#e#er5   rn   F)r)   r*   embed_tokensry   r   r   range
num_layersblockr&   rR   rq   final_layer_normrV   rW   rX   gradient_checkpointing	post_init)r0   rL   rS  r3   s    ` r4   r*   zUMT5Stack.__init__o  s       ( +]#e#e#e#eERXRcLdLd#e#e#eff
 -fn&B[ \ \ \z&"566 ',#r5   c                     | j         S r]   rS  r0   s    r4   get_input_embeddingszUMT5Stack.get_input_embeddings{  s      r5   c                     || _         d S r]   r[  r0   new_embeddingss     r4   set_input_embeddingszUMT5Stack.set_input_embeddings~  s    *r5   c                 
   |	|	n| j         j        }	|
|
n| j         j        }
||n| j         j        }||n| j         j        }|#|!| j        rdnd}t          d| d| d          |1|                                }|                    d|d                   }n@||                                d d         }n!| j        rdnd}t          d| d| d	          | j	        r%| j
        r|	rt                              d
           d}	|+| j        t          d          |                     |          }|\  }}|	du r| j        st          d|  d          d}d}| j        r|	s|t          |t                    r4t          |t                     sd}t!          |t#                                }nzt          |t                     s1d}t                              d           t!          j        |          }n4|(t!          t#                      t#                                }n	| j        sd }||                                nd}|t)          j        |||z   |j                  }|/t/                      s!||z   }t)          j        |||j                  }| j        r#|                     |||||j        nd |
          }nT|P|d d d d d d f         }|                    |j                  }d|z
  t)          j        |j                  j        z  }nd }| j        rQ|O|                                \  }}}||f}|t)          j        ||j                  }|                     |          }nd }|                      || j         j!                  }|                      || j         j!                  }|rdnd }|
rdnd }|
r	| j        rdnd }| "                    |          }tG          | j$                  D ]\  } }!||          }"||          }#|r||fz   }| j	        r,| j
        r%| %                    |!j&        |||||"|#d |	|
|          }$n |!|||||"|#||	|
|
  
        }$|$d         }|	r|$d         }%|
r||$d         fz  }| j        r||$d         fz  }| '                    |          }| "                    |          }|r||fz   }|	r|%nd }&|r|j        }&|r|(                                }&|stS          d ||&|||fD                       S tU          ||&|||          S )Ndecoder_ zYou cannot specify both zinput_ids and zinputs_embeds at the same timer8   zYou have to specify either zinput_ids or inputs_embedszZ`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`...Fz<You have to initialize the model with valid token embeddingsTz)`use_cache` can only be set to `True` if z is used as a decoderzPassing a tuple of `past_key_values` is deprecated and will be removed in Transformers v4.48.0. You should pass an instance of `EncoderDecoderCache` instead, e.g. `past_key_values=EncoderDecoderCache.from_legacy_cache(past_key_values)`.r   r   )r?   r   rK  )	r   r   r  r   r  r   r  r  r   r#   r7   r   c              3      K   | ]}||V  	d S r]   rK  )rP  r   s     r4   	<genexpr>z$UMT5Stack.forward.<locals>.<genexpr>7  s4       
 
 =  !===
 
r5   )last_hidden_statepast_key_valuesrB   
attentionscross_attentions)+rL   r  r  output_hidden_statesuse_return_dictry   r;  r   r   rX  r   r   r   rS  r^   r   r   r   from_legacy_cacher   r,   r   r   r    r-   _update_causal_maskr   r:   r?   r   r   invert_attention_maskget_head_maskrU  rX   	enumeraterV  _gradient_checkpointing_funcrD   rW  to_legacy_cachetupler   )'r0   r  r   r   r  re  	head_maskcross_attn_head_maskrj  r  r  rm  return_dictr   err_msg_prefixinput_shaper   r   return_legacy_cachereturn_self_attention_cachepast_key_values_lengthmask_seq_lengthr   encoder_batch_sizeencoder_sequence_length_encoder_hidden_shapeencoder_extended_attention_maskall_hidden_statesall_attentionsall_cross_attentionsrB   rQ  layer_moduler   r  layer_outputsnext_decoder_cache
next_caches'                                          r4   rD   zUMT5Stack.forward  s     "+!6IIDK<Q	1B1N--TXT_Tq$8$D  $+Jj 	 &1%<kk$+B] ]%>+/?BZZNw>wwwww   "#..**K!r;r?;;II&',,..ss3KK+/?BZZNu>uuXfuuuvvv& 	"4= 	" "##p   "	  ( !_``` --i88M!,
J? j !hT!h!h!hiii $&+#? 	#	 	#_-H/511 V*_Vi:j:j V.2+"5o|~~"V"V1DEE 	V&*###`  
 #6"G"X"X ("5lnnlnn"U"U 	# #OETE`!?!?!A!A!Afg!"\&(>(KTaTh  N !*B*D*D!4zAO"Z
OML`aaaN? 	228G8S44Y]! KK '(D$)9:K%..}/B.CCK,M<O0P0P0TTKKK ? 	34@=R=W=W=Y=Y: 7$68O#P %-).4HQ^Qe)f)f)f&.2.H.HI_.`.`++.2+ &&y$+2HII	#112FH^__"6@BBD0:d%6T4?TrrPT]33(44 +	@ +	@OA|'lO)=a)@&# I$58H$H!* 1t} 1 $ A A (!)3#.%"! ! !-!#.*?+J$3/I#2'&7#1! ! ! !.a 0 6%21%5"  @=#3"55? @(]1-=,??(--m<<]33   	E 1]4D D+4>''$
& 	>(=J 	;(88::J 	 
 
 "%"(
 
 
 
 
 
 9+&+%1
 
 
 	
r5   r   input_tensorr   rj  r  c           
         | j         j        dk    r
|d|v r|S d S ||                                nd}t          |t                    }| j         j        dk    r#|s!|st          j        |||| j                  rd S |j        |j	        }	}|j
        d         }
|r|                                }n/t          |t          j                  r|j
        d         n||
z   dz   }|                     ||
|||	||j
        d                   }| j         j        dk    rB|@|j	        j        d	k    r0|s.t          j        |          j        }t          j        ||          }|S )
Nflash_attention_2r!  r   sdpa)re  r~  is_trainingr#   r8   )sequence_lengthtarget_lengthr?   r   r   r   cuda)rL   _attn_implementationr   r^   r   r   _ignore_causal_mask_sdpar   r?   r   r   get_max_cache_shaper,   r_   5_prepare_4d_causal_attention_mask_with_cache_positiontyper   r   _unmask_unattended)r0   r   r  r   rj  r  past_seen_tokensusing_static_cacher?   r   r  r  r   	min_dtypes                 r4   rp  zUMT5Stack._update_causal_maskK  s    ;+/BBB)c^.C.C%%4
 @O?Z?99;;;`a'EE ;+v55>P5Yj5%>*'7 M	    t$*L,?v&,Q/ 	+??AAMM nel;;<$R((%7!;  PP+')#)!, Q 
 
 K,66*%*f44% 5 E**.I0CKQZ[[Kr5   r  r  r?   r   r   c                    | |                                  dk    r| }n+t          j        |          j        }	t          j        ||f|	||          }|dk    rt          j        |d          }|t          j        ||          |                    dd          k    z  }|ddddddf                             |ddd          }| |	                                }| j
        d         }
|ddddddd|
f         | ddddddf         z   }|dk    }|ddddddd|
f                             ||	          |ddddddd|
f<   |S )	a  
        Creates a causal 4D mask of shape `(batch_size, 1, query_length, key_value_length)` from a 2D mask of shape
        `(batch_size, key_value_length)`, or if the input `attention_mask` is already 4D, do nothing.

        Args:
            attention_mask (`torch.Tensor`):
                A 2D attention mask of shape `(batch_size, key_value_length)` or a 4D attention mask of shape
                `(batch_size, 1, query_length, key_value_length)`.
            sequence_length (`int`):
                The sequence length being processed.
            target_length (`int`):
                The target length: when generating with static cache, the mask should be as long as the static cache,
                to account for the 0 padding, the part of the cache that is not filled yet.
            dtype (`torch.dtype`):
                The dtype to use for the 4D attention mask.
            device (`torch.device`):
                The device to plcae the 4D attention mask on.
            cache_position (`torch.Tensor`):
                Indices depicting the position of the input sequence tokens in the sequence.
            batch_size (`torch.Tensor`):
                Batch size.
        N   )
fill_valuer?   r   r#   )diagonalrf  r8   r   )r   r,   r   r   r<  triur   reshapeexpandr?  r   masked_fill)r   r  r  r?   r   r   r   kwargsr   r  mask_lengthpadding_masks               r4   r  z?UMT5Stack._prepare_4d_causal_attention_mask_with_cache_position  s   D %.*<*<*>*>!*C*C(KKE**.I* -0Ye\b  K !###jqAAA5<fEEEH^H^_acdHeHeeeK%dD!!!QQQ&67>>z1bRTUUK))//11,226*111aaaL[L+@ANSTSTSTVZ\`bcbcbcScDdd+q05@AAAqqq,;,AV5W5c5c )6 6AAAqqq!!!\k\12 r5   r]   )NNNNNNNNNNNNN)rE   rF   rG   r*   r]  ra  rD   r,   r_   r   r   rp  staticmethodr   r?   r   r  rH   rI   s   @r4   rM  rM  n  sR       
 
 
 
 
 
! ! !+ + +
 "#!!G
 G
 G
 G
T?? l? 	?
 ?  ? ? ? ?B 555 5 {	5
 5 5 5 5 5 \5 5 5 5 5r5   rM  a  

    The UMT5 model was proposed in [Exploring the Limits of Transfer Learning with a Unified Text-to-Text
    Transformer](https://arxiv.org/abs/1910.10683) by Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan
    Narang, Michael Matena, Yanqi Zhou, Wei Li, Peter J. Liu. It's an encoder decoder transformer pre-trained in a
    text-to-text denoising generative setting.

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

    This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
    Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
    and behavior.

    Parameters:
        config ([`UMT5Config`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
a  
    Args:
        input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
            Indices of input sequence tokens in the vocabulary. UMT5 is a model with relative position embeddings so
            you should be able to pad the inputs on both the right and the left.

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

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

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

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

            [What are attention masks?](../glossary#attention-mask)
        decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
            Indices of decoder input sequence tokens in the vocabulary.

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

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

            UMT5 uses the `pad_token_id` as the starting token for `decoder_input_ids` generation. If `past_key_values`
            is used, optionally only the last `decoder_input_ids` have to be input (see `past_key_values`).

            To know more on how to prepare `decoder_input_ids` for pretraining take a look at [UMT5
            Training](./umt5#training).
        decoder_attention_mask (`torch.BoolTensor` of shape `(batch_size, target_sequence_length)`, *optional*):
            Default behavior: generate a tensor that ignores pad tokens in `decoder_input_ids`. Causal mask will also
            be used by default.
        head_mask (`torch.FloatTensor` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*):
            Mask to nullify selected heads of the self-attention modules in the encoder. Mask values selected in `[0,
            1]`:

            - 1 indicates the head is **not masked**,
            - 0 indicates the head is **masked**.

        decoder_head_mask (`torch.FloatTensor` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*):
            Mask to nullify selected heads of the self-attention modules in the decoder. Mask values selected in `[0,
            1]`:

            - 1 indicates the head is **not masked**,
            - 0 indicates the head is **masked**.

        cross_attn_head_mask (`torch.Tensor` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*):
                Mask to nullify selected heads of the cross-attention modules in the decoder. Mask values selected in
                `[0, 1]`:

                - 1 indicates the head is **not masked**,
                - 0 indicates the head is **masked**.

        encoder_outputs (`tuple(tuple(torch.FloatTensor)`, *optional*):
            Tuple consists of (`last_hidden_state`, `optional`: *hidden_states*, `optional`: *attentions*)
            `last_hidden_state` of shape `(batch_size, sequence_length, hidden_size)` is a sequence of hidden states at
            the output of the last layer of the encoder. Used in the cross-attention of the decoder.
        past_key_values (`tuple(tuple(torch.FloatTensor))` of length `config.n_layers` with each tuple having 4 tensors of shape `(batch_size, num_heads, sequence_length - 1, embed_size_per_head)`):
            Contains precomputed key and value hidden states of the attention blocks. Can be used to speed up decoding.

            If `past_key_values` are used, the user can optionally input only the last `decoder_input_ids` (those that
            don't have their past key value states given to this model) of shape `(batch_size, 1)` instead of all
            `decoder_input_ids` of shape `(batch_size, sequence_length)`.
        inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
            Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
            is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
            model's internal embedding lookup matrix.
        decoder_inputs_embeds (`torch.FloatTensor` of shape `(batch_size, target_sequence_length, hidden_size)`, *optional*):
            Optionally, instead of passing `decoder_input_ids` you can choose to directly pass an embedded
            representation. If `past_key_values` is used, optionally only the last `decoder_inputs_embeds` have to be
            input (see `past_key_values`). This is useful if you want more control over how to convert
            `decoder_input_ids` indices into associated vectors than the model's internal embedding lookup matrix.

            If `decoder_input_ids` and `decoder_inputs_embeds` are both unset, `decoder_inputs_embeds` takes the value
            of `inputs_embeds`.

        use_cache (`bool`, *optional*):
            If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
            `past_key_values`).

        output_attentions (`bool`, *optional*):
            Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
            tensors for more detail.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
        cache_position (`torch.LongTensor` of shape `(sequence_length)`, *optional*):
            Indices depicting the position of the input sequence tokens in the sequence. It is used to update the
            cache in the correct position and to infer the complete sequence length.
a  
    Args:
        input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
            Indices of input sequence tokens in the vocabulary. UMT5 is a model with relative position embeddings so
            you should be able to pad the inputs on both the right and the left.

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

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

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

            [What are attention masks?](../glossary#attention-mask)
        head_mask (`torch.FloatTensor` of shape `(num_heads,)` or `(num_layers, num_heads)`, *optional*):
            Mask to nullify selected heads of the self-attention modules. Mask values selected in `[0, 1]`:

            - 1 indicates the head is **not masked**,
            - 0 indicates the head is **masked**.

        inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
            Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
            is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
            model's internal embedding lookup matrix.
        output_attentions (`bool`, *optional*):
            Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
            tensors for more detail.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
z^The bare UMT5 Model transformer outputting raw hidden-states without any specific head on top.c            '           e Zd ZdZdZeZddgZ fdZd Z	d Z
d Zd	 Zd
 Zd Z ee           eee          	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d deej                 deej                 deej                 deej                 deej                 deej                 deej                 deeeej                                   deeeej                                   deej                 deej                 dee         dee         dee         dee         deej                 deeej                 ef         f"d                        Z xZS )!r*  ao  
    Examples:

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

    >>> model = UMT5Model.from_pretrained("google/umt5-small")
    >>> tokenizer = AutoTokenizer.from_pretrained("google/umt5-small")
    >>> noisy_text = "UN Offizier sagt, dass weiter <extra_id_0> werden muss in Syrien."
    >>> label = "<extra_id_0> verhandelt"
    >>> inputs = tokenizer(inputs, return_tensors="pt")
    >>> labels = tokenizer(label=label, return_tensors="pt")

    >>> outputs = model(input_ids=inputs["input_ids"], decoder_input_ids=labels["input_ids"])
    >>> hidden_states = outputs.last_hidden_state
    ```umt5encoder.embed_tokens.weightdecoder.embed_tokens.weightc                    t                                          |           t          j        |j        |j                  | _        t          j        |          }d|_	        d|_
        d|_        t          || j                  | _        t          j        |          }d|_	        d|_        |j        |_        t          || j                  | _        |                                  d S NFT)r)   r*   r   r   
vocab_sizerR   r.  copydeepcopyry   r  is_encoder_decoderrM  encodernum_decoder_layersrU  decoderrY  r0   rL   encoder_configdecoder_configr3   s       r4   r*   zUMT5Model.__init__{  s       l6#4fnEEv..$)!#( ,1) ==v..$(!,1)$*$=! == 	r5   c                     | j         S r]   r.  r\  s    r4   r]  zUMT5Model.get_input_embeddings  
    {r5   c                 |    || _         | j                            |           | j                            |           d S r]   r.  r  ra  r  r_  s     r4   ra  zUMT5Model.set_input_embeddings  ;    $)).999)).99999r5   c                     | j         j        rL|                     | j        j        | j                   |                     | j        j        | j                   d S d S r]   rL   r1  _tie_or_clone_weightsr  rS  r.  r  r\  s    r4   _tie_weightszUMT5Model._tie_weights  \    ;* 	O&&t|'@$+NNN&&t|'@$+NNNNN	O 	Or5   c                     | j         S r]   r  r\  s    r4   get_encoderzUMT5Model.get_encoder  
    |r5   c                     | j         S r]   r  r\  s    r4   get_decoderzUMT5Model.get_decoder  r  r5   c                     |                                 D ]/\  }}| j        j        |         j                            |           0dS )
        Prunes heads of the model. heads_to_prune: dict of {layer_num: list of heads to prune in this layer} See base
        class PreTrainedModel
        N)itemsr  r   	attentionprune_headsr0   heads_to_pruner   headss       r4   _prune_headszUMT5Model._prune_heads  sU    
 +0022 	C 	CLE5Lu%/;;EBBBB	C 	Cr5   output_typerC  Nr  r   r  r  rw  decoder_head_maskrx  encoder_outputsrj  re  decoder_inputs_embedsr  r  rm  ry  r   r   c                 *   ||n| j         j        }||n| j         j        }||                     |||
||||          }ne|rct	          |t
                    sNt          |d         t          |          dk    r|d         ndt          |          dk    r|d         nd          }|d         }|                     ||||	|||||||||          }|s||z   S t          |j	        |j
        |j        |j        |j        |j	        |j        |j                  S )	a  
        Returns:

        Example:

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

        >>> tokenizer = AutoTokenizer.from_pretrained("google/umt5-small")
        >>> model = UMT5Model.from_pretrained("google/umt5-small")

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

        >>> # preprocess: Prepend decoder_input_ids with start token which is pad token for UMT5Model.
        >>> # This is not needed for torch's UMT5ForConditionalGeneration as it does this internally using labels arg.
        >>> decoder_input_ids = model._shift_right(decoder_input_ids)

        >>> # forward pass
        >>> outputs = model(input_ids=input_ids, decoder_input_ids=decoder_input_ids)
        >>> last_hidden_states = outputs.last_hidden_state
        ```Nr  r   re  rw  r  rm  ry  r   r#   r7   ri  rB   rk  r  r   re  rj  r   r  rw  rx  r  r  rm  ry  r   )ri  rj  decoder_hidden_statesdecoder_attentionsrl  encoder_last_hidden_stater   encoder_attentions)rL   r  rn  r  r^   r   lenr  r   ri  rj  rB   rk  rl  )r0   r  r   r  r  rw  r  rx  r  rj  re  r  r  r  rm  ry  r   rB   decoder_outputss                      r4   rD   zUMT5Model.forward  s   Z "+!6IIDK<Q	%0%<kk$+B] ""ll#-+#"3%9' +  OO  	O_!M!M 	-"1!"4474H4H14L4Loa00RV14_1E1E1I1I?1--t  O (* ,,'1/+"/#1'!5/!5#) ' 
 
   	5"_44!-?+;"1"?.9,=&5&G"1"?.9	
 	
 	
 		
r5   NNNNNNNNNNNNNNNN)rE   rF   rG   r   
model_typer$   rC  _tied_weights_keysr*   r]  ra  r  r  r  r  r   UMT5_INPUTS_DOCSTRINGr"   r   _CONFIG_FOR_DOCr   r,   
LongTensorFloatTensor
BoolTensorr_   r   r   r   rD   rH   rI   s   @r4   r*  r*  a  s       
 " JL79VW    (  : : :O O O    C C C +*+@AA+=O\\\ 156:8<=A159=7;EIEI048<$(,0/3&*59#_
 _
E,-_
 !!23_
 $E$45	_

 !))9 :_
 E-._
 $E$56_
 'u|4_
 "%e.?(@"AB_
 "%e.?(@"AB_
  -_
  (5_
 D>_
 $D>_
 'tn_
  d^!_
" !!12#_
$ 
uU&');;	<%_
 _
 _
 ]\ BA_
 _
 _
 _
 _
r5   r*  z2UMT5 Model with a `language modeling` head on top.c            )           e Zd ZdZdZg dZ fdZd Zd Zd Z	d Z
d	 Zd
 Zd Z ee           eee          	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d#deej                 deej                 deej                 deej                 deej                 deej                 deej                 deeeej                                   deeeej                                   deej                 deej                 deej                 dee         dee         dee         dee         deej                 deeej                 ef         f$d                         Zdej        fd!Zed"             Z xZ S )$r+  a  
    Examples:

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

    >>> model = UMT5ForConditionalGeneration.from_pretrained("google/umt5-small")
    >>> tokenizer = AutoTokenizer.from_pretrained("google/umt5-small")
    >>> article = "UN Offizier sagt, dass weiter verhandelt werden muss in Syrien."
    >>> summary = "Weiter Verhandlung in Syrien."
    >>> inputs = tokenizer(article, text_target=summary, return_tensors="pt")

    >>> outputs = model(**inputs)
    >>> loss = outputs.loss
    ```r  )r  r  zlm_head.weightc                 4   t                                          |           |j        | _        t	          j        |j        |j                  | _        t          j	        |          }d|_
        d|_        d|_        t          || j                  | _        t          j	        |          }d|_
        d|_        |j        |_        t          || j                  | _        t	          j        |j        |j        d          | _        |                                  d S )NFTrO   )r)   r*   rR   	model_dimr   r   r  r.  r  r  ry   r  r  rM  r  r  rU  r  rQ   r#  rY  r  s       r4   r*   z%UMT5ForConditionalGeneration.__init__(  s       l6#4fnEEv..$)!#( ,1) ==v..$(!,1)$*$=! ==y1BOOO 	r5   c                     | j         S r]   r  r\  s    r4   r]  z1UMT5ForConditionalGeneration.get_input_embeddings@  r  r5   c                 |    || _         | j                            |           | j                            |           d S r]   r  r_  s     r4   ra  z1UMT5ForConditionalGeneration.set_input_embeddingsD  r  r5   c                     | j         j        rL|                     | j        j        | j                   |                     | j        j        | j                   d S d S r]   r  r\  s    r4   r  z)UMT5ForConditionalGeneration._tie_weightsJ  r  r5   c                     || _         d S r]   r#  r_  s     r4   set_output_embeddingsz2UMT5ForConditionalGeneration.set_output_embeddingsP  s    %r5   c                     | j         S r]   r  r\  s    r4   get_output_embeddingsz2UMT5ForConditionalGeneration.get_output_embeddingsT  r  r5   c                     | j         S r]   r  r\  s    r4   r  z(UMT5ForConditionalGeneration.get_encoderX  r  r5   c                     | j         S r]   r  r\  s    r4   r  z(UMT5ForConditionalGeneration.get_decoder\  r  r5   r  Nr  r   r  r  rw  r  rx  r  rj  re  r  labelsr  r  rm  ry  r   r   c                    ||n| j         j        }||n| j         j        }||                     |||
||||          }ne|rct	          |t
                    sNt          |d         t          |          dk    r|d         ndt          |          dk    r|d         nd          }|d         }||||                     |          }|                     ||||	|||||||||          }|d         }| j         j	        r|| j
        dz  z  }|                     |          }d}|pt          d	
          }|                    |j                  } ||                    d|                    d                    |                    d                    }|s|f|dd         z   |z   }||f|z   n|S t#          |||j        |j        |j        |j        |j        |j        |j        	  	        S )a  
        labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
            Labels for computing the sequence classification/regression loss. Indices should be in `[-100, 0, ...,
            config.vocab_size - 1]`. All labels set to `-100` are ignored (masked), the loss is only computed for
            labels in `[0, ..., config.vocab_size]`

        Returns:

        Examples:

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

        >>> tokenizer = AutoTokenizer.from_pretrained("google/umt5-small")
        >>> model = UMT5ForConditionalGeneration.from_pretrained("google/umt5-small")

        >>> # training
        >>> input_ids = tokenizer("The <extra_id_0> walks in <extra_id_1> park", return_tensors="pt").input_ids
        >>> labels = tokenizer("<extra_id_0> cute dog <extra_id_1> the <extra_id_2>", return_tensors="pt").input_ids
        >>> outputs = model(input_ids=input_ids, labels=labels)
        >>> loss = outputs.loss
        >>> logits = outputs.logits

        >>> # inference
        >>> input_ids = tokenizer("Studies have shown that <extra_id_0> good for you", return_tensors="pt").input_ids
        >>> outputs = model.generate(input_ids)
        >>> tokenizer.decode(outputs[0], skip_special_tokens=True)
        ```Nr  r   r#   r7   r  r  r%  r8  ignore_indexr8   	losslogitsrj  r  r  rl  r  r   r  )rL   r  rn  r  r^   r   r  rB  r  r1  r  r#  r	   r:   r   r   r   r   rj  rB   rk  rl  ri  )r0   r  r   r  r  rw  r  rx  r  rj  re  r  r  r  r  rm  ry  r   rB   r  sequence_output	lm_logitsr  loss_fctoutputs                            r4   rD   z$UMT5ForConditionalGeneration.forward_  so   d "+!6IIDK<Q	%0%<kk$+B] ""ll#-+#"3%9' +  OO  	O_!M!M 	-"1!"4474H4H14L4Loa00RV14_1E1E1I1I?1--t  O (*"3";@U@] $ 1 1& 9 9 ,,'1/+"/#1'!5/!5#) ' 
 
  *!,;* 	G .1EFOLL11	'T:::HYYy/00F8INN2y~~b/A/ABBFKKPROOTTD 	F\OABB$77/IF)-)9TGf$$vE+;"1"?.9,=&5&G"1"?.9

 

 

 
	
r5   c                 ,    |                      |          S r]   )rB  )r0   r  s     r4   %prepare_decoder_input_ids_from_labelszBUMT5ForConditionalGeneration.prepare_decoder_input_ids_from_labels  s      (((r5   c                 T    d}| D ]!}|t          fd|D                       fz  }"|S )NrK  c              3   t   K   | ]2}|                     d                     |j                            V  3dS )r   N)index_selectr:   r   )rP  
past_statebeam_idxs     r4   rh  z>UMT5ForConditionalGeneration._reorder_cache.<locals>.<genexpr>  sC      nnU_j--aZ=N1O1OPPnnnnnnr5   )rv  )rj  r	  reordered_past
layer_pasts    `  r4   _reorder_cachez+UMT5ForConditionalGeneration._reorder_cache  sQ    ) 	 	Jnnnncmnnnnn NN r5   )NNNNNNNNNNNNNNNNN)!rE   rF   rG   r   r  r  r*   r]  ra  r  r  r  r  r  r   r  r"   r   r  r   r,   r  r  r  r_   r   r   r   rD   r  r  r  rH   rI   s   @r4   r+  r+    s          Jiii    0  : : :O O O& & &       +*+@AA?YYY 156:8<=A159=7;@D@D59=A-1$(,0/3&*59%{
 {
E,-{
 !!23{
 $E$45	{

 !))9 :{
 E-.{
 $E$56{
 'u|4{
 "%el(;"<={
 "%el(;"<={
   12{
  ((9:{
 )*{
 D>{
 $D>{
  'tn!{
" d^#{
$ !!12%{
& 
uU&'8	9'{
 {
 {
 ZY BA{
|)EL ) ) ) )   \    r5   r+  zhThe bare UMT5 Model transformer outputting encoder's raw hidden-states without any specific head on top.c                   l    e Zd ZdZdZdgZ fdZd Zd Zd Z	d Z
d	 Z ee           eee
          	 	 	 	 	 	 	 ddeej                 deej                 deej                 deej                 dee         dee         dee         deeej                 ef         fd                        Z xZS )r,  a  
    Examples:

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

    >>> model = UMT5EncoderModel.from_pretrained("google/umt5-small")
    >>> tokenizer = AutoTokenizer.from_pretrained("google/umt5-small")
    >>> article = "UN Offizier sagt, dass weiter verhandelt werden muss in Syrien."
    >>> input_ids = tokenizer(article, return_tensors="pt").input_ids
    >>> outputs = model(input_ids)
    >>> hidden_state = outputs.last_hidden_state
    ```r  r  c                 2   t                                          |           t          j        |j        |j                  | _        t          j        |          }d|_	        d|_
        t          || j                  | _        |                                  d S NF)r)   r*   r   r   r  rR   r.  r  r  r  r  rM  r  rY  )r0   rL   r  r3   s      r4   r*   zUMT5EncoderModel.__init__  s}       l6#4fnEEv..#( ,1) == 	r5   c                     | j         S r]   r  r\  s    r4   r]  z%UMT5EncoderModel.get_input_embeddings  r  r5   c                 H    || _         | j                            |           d S r]   )r.  r  ra  r_  s     r4   ra  z%UMT5EncoderModel.set_input_embeddings  s%    $)).99999r5   c                 l    | j         j        r'|                     | j        j        | j                   d S d S r]   )rL   r1  r  r  rS  r.  r\  s    r4   r  zUMT5EncoderModel._tie_weights  s?    ;* 	O&&t|'@$+NNNNN	O 	Or5   c                     | j         S r]   r  r\  s    r4   r  zUMT5EncoderModel.get_encoder  r  r5   c                     |                                 D ]:\  }}| j        j        |         j        d         j                            |           ;dS )r  r   N)r  r  rV  r   r   r  r  s       r4   r  zUMT5EncoderModel._prune_heads"  s]    
 +0022 	P 	PLE5Lu%+A.<HHOOOO	P 	Pr5   r  Nr  r   rw  re  r  rm  ry  r   c           	      ^    ||n| j         j        }|                     |||||||          }|S )a5  
        Returns:

        Example:

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

        >>> tokenizer = AutoTokenizer.from_pretrained("google/umt5-small")
        >>> model = UMT5EncoderModel.from_pretrained("google/umt5-small")
        >>> input_ids = tokenizer(
        ...     "Studies have been shown that owning a dog is good for you", return_tensors="pt"
        ... ).input_ids  # Batch size 1
        >>> outputs = model(input_ids=input_ids)
        >>> last_hidden_states = outputs.last_hidden_state
        ```Nr  )rL   rn  r  )	r0   r  r   rw  re  r  rm  ry  r  s	            r4   rD   zUMT5EncoderModel.forward*  sL    : &1%<kk$+B],,)'/!5# ' 
 
 r5   )NNNNNNN)rE   rF   rG   r   r  r  r*   r]  ra  r  r  r  r   UMT5_ENCODER_INPUTS_DOCSTRINGr"   r   r  r   r,   r  r  r   r   r   rD   rH   rI   s   @r4   r,  r,    s       
  J78
 
 
 
 
  : : :
O O O
  P P P +*+HII?YYY 156:1559,0/3&*& &E,-& !!23& E-.	&
   12& $D>& 'tn& d^& 
uU&'8	9& & & ZY JI& & & & &r5   r,  z
    UMT5 model with a sequence classification/head on top (a linear layer on top of the pooled output) e.g. for GLUE
    tasks.
    c            %           e Zd ZdgZddgZdef fdZ ee           e	e
e          	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddej        d	eej                 d
eej                 deej                 deej                 deej                 deej                 deeej                          deej                 deej                 deej                 dee         dee         dee         dee         deee
f         f d                        Z xZS )UMT5ForSequenceClassificationFdecoder.block.0.layer.1.EncDecAttention.relative_attention_bias.weightr  r  rL   c                     t                                          |           t          |          | _        t	          |          | _        |                                  d| _        d S r  )r)   r*   r*  r  r  classification_headrY  model_parallelr[   s     r4   r*   z&UMT5ForSequenceClassification.__init__b  s[       $V,,#9&#A#A  	#r5   r  Nr  r   r  r  rw  r  rx  r  re  r  r  r  r  rm  ry  r   c                 p   ||n| j         j        }|d}||	t          d| j        j                   |(|
&|t          d          |                     |          }|                     |||||||||	|
||||          }|d         }|                    | j         j	                  
                    |j                  }t          t          j        |                    d                              dk    rt          d          |j        \  }}}||ddf                             |d	|          ddd	ddf         }|                     |          }d}||
                    |j                  }| j         j        p| j         j        dk    rd
| j         _        nS| j         j        dk    r7|j        t          j        k    s|j        t          j        k    rd| j         _        nd| j         _        | j         j        d
k    r\t1                      }| j         j        dk    r1 ||                                |                                          }n |||          }n| j         j        dk    rLt5                      } ||                    d	| j         j                  |                    d	                    }n*| j         j        dk    rt7                      } |||          }|s|f|dd         z   }||f|z   n|S t9          |||j        |j        |j        |j         |j!        |j"        |j#        	  	        S )aD  
        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 classification loss is computed (Cross-Entropy).
        Returns:
        NFz8Passing input embeddings is currently not supported for If no `decoder_input_ids` or `decoder_inputs_embeds` are passed, `input_ids` cannot be `None`. Please pass either `input_ids` or `decoder_input_ids` or `decoder_inputs_embeds`.)r   r  r  rw  r  rx  r  re  r  r  r  rm  ry  r   r#   z7All examples must have the same number of <eos> tokens.r8   
regressionsingle_label_classificationmulti_label_classificationr  )$rL   rn  NotImplementedErrorr3   rE   r;  rB  r  eqeos_token_idr:   r   r  r,   unique_consecutivesumr   r   r  problem_typer  r?   r   r   r
   squeezer	   r   r   rj  r  r  rl  r  r   r  )r0   r  r   r  r  rw  r  rx  r  re  r  r  r  r  rm  ry  r   r  eos_maskr   r  r1   sentence_representationr  r  r  r  s                              r4   rD   z%UMT5ForSequenceClassification.forwardl  s   4 &1%<kk$+B]I!:%d4>Kbdd   $)>)F  U  
 !% 1 1) < <"")/#9/!5+'"7/!5# # 
 
  "!*<< 899<<_=STTu'Q8899A==VWWW%4%:"
A{"1(AAA+">"C"CJPRT_"`"`abababdfhihihiai"j))*ABBYYv}--F{'/;)Q../;DK,,[+a//V\UZ5O5OSYS_chclSlSl/LDK,,/KDK,{'<77"99;)Q..#8FNN$4$4fnn6F6FGGDD#8FF33DD)-JJJ+--xB0F G GUWYY)-III,..x// 	FY,F)-)9TGf$$vE.#3")"?&9$5&-&G")"?&9

 

 

 
	
r5   )NNNNNNNNNNNNNNN)rE   rF   rG   "_keys_to_ignore_on_load_unexpectedr  r$   r*   r   r  r"   r   r  r,   r  r   r_   r   r  r   r   r   rD   rH   rI   s   @r4   r  r  V  s        +s)s&79VW$z $ $ $ $ $ $ +*+@AA+JYhiii '+158<=A,0487;=A59=A-1$(,0/3&*!k
 k
#k
 !.k
 $E$45	k

 !))9 :k
 EL)k
 $EL1k
 'u|4k
 "$u'8"9:k
   12k
  ((9:k
 )*k
 D>k
 $D>k
 'tnk
  d^!k
" 
u55	6#k
 k
 k
 ji BAk
 k
 k
 k
 k
r5   r  z
    UMT5 Encoder Model with a token classification head on top (a linear layer on top of the hidden-states output)
    e.g. for Named-Entity-Recognition (NER) tasks.
    c                   n    e Zd ZdgZdgZdef fdZ ee           e	e
e          	 	 	 	 	 	 	 	 ddeej                 deej                 d	eej                 d
eej                 deej                 dee         dee         dee         deeej                 e
f         fd                        Z xZS )r3  r  z'transformer.encoder.embed_tokens.weightrL   c                 6   t                                          |           |j        | _        t          |          | _        t          j        |j                  | _        t          j	        |j
        |j                  | _        |                                  d S r]   )r)   r*   r  r,  r  r   rV   r  rX   rQ   r1   r&  rY  r[   s     r4   r*   z#UMT5ForTokenClassification.__init__  sz        ++F33z&";<<)F$68IJJ 	r5   r  Nr  r   rw  re  r  r  rm  ry  r   c	           	         ||n| j         j        }|                     |||||||          }	|	d         }
|                     |
          }
|                     |
          }d}|Ft                      } ||                    d| j                  |                    d                    }|s||	dd         f}||f|z   n|S t          |||	j	        |	j
                  S )z
        labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
            Labels for computing the token classification loss. Indices should be in `[0, ..., config.num_labels - 1]`.
        Returns:
        N)r   rw  re  r  rm  ry  r   r8   r7   )r  r  rB   rk  )rL   rn  r  rX   r&  r	   r   r  r   rB   rk  )r0   r  r   rw  re  r  r  rm  ry  r   rB   r  r  r  r  s                  r4   rD   z"UMT5ForTokenClassification.forward  s   & &1%<kk$+B]"")'/!5# # 
 
  
]33//'))H8FKKDO<<fkk"ooNND 	Fgadm,F)-)9TGf$$vE$!/)	
 
 
 	
r5   )NNNNNNNN)rE   rF   rG   r+  r  r$   r*   r   r  r"   r   r  r   r,   r_   r   r   r   rD   rH   rI   s   @r4   r3  r3    s\        +s)s&CD	z 	 	 	 	 	 	 +*+@AA+@___ -115,004)-,0/3&*.
 .
EL).
 !..
 EL)	.

  -.
 &.
 $D>.
 'tn.
 d^.
 
uU\"$99	:.
 .
 .
 `_ BA.
 .
 .
 .
 .
r5   r3  z
    UMT5 Model with a span classification head on top for extractive question-answering tasks like SQuAD (linear layers
    on top of the hidden-states output to compute `span start logits` and `span end logits`).
    c            '       p    e Zd ZddgZ fdZd Zd Zd Zd Zd Z	 e
e           eee	          	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddeej                 deej                 deej                 deej                 deej                 deej                 deej                 deeeej                                   deej                 deej                 deej                 deej                 dee         dee         dee         dee         deeej                 ef         f"d                        Z xZS )r-  r  r  c                 H   t                                          |           |j        | _        t	          j        |j        |j                  | _        t          j	        |          }d|_
        d|_        d|_        t          || j                  | _        t          j	        |          }d|_
        d|_        |j        |_        t          || j                  | _        |j        | _        t	          j        |j        |j                  | _        |                                  d S r  )r)   r*   rR   r  r   r   r  r.  r  r  ry   r  r  rM  r  r  rU  r  r  rQ   r$  rY  r  s       r4   r*   z!UMT5ForQuestionAnswering.__init__1  s       l6#4fnEEv..$)!#( ,1) ==v..$(!,1)$*$=! == +)FNF4EFF 	r5   c                     | j         S r]   r  r\  s    r4   r]  z-UMT5ForQuestionAnswering.get_input_embeddingsJ  r  r5   c                 |    || _         | j                            |           | j                            |           d S r]   r  r_  s     r4   ra  z-UMT5ForQuestionAnswering.set_input_embeddingsN  r  r5   c                     | j         j        rL|                     | j        j        | j                   |                     | j        j        | j                   d S d S r]   r  r\  s    r4   r  z%UMT5ForQuestionAnswering._tie_weightsT  r  r5   c                     | j         S r]   r  r\  s    r4   r  z$UMT5ForQuestionAnswering.get_encoderZ  r  r5   c                     | j         S r]   r  r\  s    r4   r  z$UMT5ForQuestionAnswering.get_decoder^  r  r5   r  Nr  r   r  r  rw  r  rx  r  start_positionsend_positionsre  r  r  r  rm  ry  r   c                 4   ||n| j         j        }||n| j         j        }|	|
d}|(|&|t          d          |                     |          }||n| j         j        }||n| j         j        }||                     |||||||          }ne|rct          |t                    sNt          |d         t          |          dk    r|d         ndt          |          dk    r|d         nd          }|d         }| 	                    |||d||||||||	          }|d         }| 
                    |          }|                    dd
          \  }}|                    d
                                          }|                    d
                                          }d}|	|
t          |	                                          dk    r-|	                    d
                              |j                  }	t          |
                                          dk    r-|
                    d
                              |j                  }
|                    d          }|	                    d|          }	|
                    d|          }
t%          |          } |||	          } |||
          }||z   dz  }|s||f|dd         z   |z   }||f|z   n|S t'          ||||j        |j        |j        |j        |j        |j        |j        
  
        S )a  
        start_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
            Labels for position (index) of the start of the labelled span for computing the token classification loss.
            Positions are clamped to the length of the sequence (*sequence_length*). Position outside of the sequence
            are not taken into account for computing the loss.
        end_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
            Labels for position (index) of the end of the labelled span for computing the token classification loss.
            Positions are clamped to the length of the sequence (*sequence_length*). Position outside of the sequence
            are not taken into account for computing the loss.
        Returns:
        NFr  r  r   r#   r7   r  )r  r   re  rj  r   r  rw  rx  r  r  rm  ry  r8   r   r  )
r  start_logits
end_logitsrj  r  r  rl  r  r   r  )rL   rn  r  r;  rB  r  r^   r   r  r  r$  splitr(  r   r   r:   r   r  r	   r   rj  rB   rk  rl  ri  )r0   r  r   r  r  rw  r  rx  r  r6  r7  re  r  r  r  rm  ry  rB   r  r  r  r9  r:  
total_lossignored_indexr  
start_lossend_lossr  s                                r4   rD   z UMT5ForQuestionAnswering.forwarda  s   @ &1%<kk$+B]!*!6IIDK<Q	&=+DI
 $)>)F  U  
 !% 1 1) < <!*!6IIDK<Q	%0%<kk$+B] ""ll#-+#"3%9' +  OO  	O_!M!M 	-"1!"4474H4H14L4Loa00RV14_1E1E1I1I?1--t  O (* ,,'1/ "/#1'!5/!5# ' 
 
 *!,11#)<<r<#:#: j#++B//::<<''++6688

&=+D?''))**Q.."1"9"9""="="@"@AT"U"U=%%''((1,, - 5 5b 9 9 < <Z=N O O(--a00M-33A}EEO)//=AAM']CCCH!,@@Jx
M::H$x/14J 	R"J//!""2EEWF/9/EZMF**6Q2%!+;"1"?.9,=&5&G"1"?.9
 
 
 	
r5   r  )rE   rF   rG   r  r*   r]  ra  r  r  r  r   r  r"   r   r  r   r,   r  r  r  r_   r   r   r   rD   rH   rI   s   @r4   r-  r-  '  sd        89VW    2  : : :O O O     +*+@AA+N]lmmm 156:8<=A159=7;@D6:4859=A$(,0/3&*#}
 }
E,-}
 !!23}
 $E$45	}

 !))9 :}
 E-.}
 $E$56}
 'u|4}
 "%el(;"<=}
 "%"23}
   01}
   12}
  ((9:}
 D>}
 $D>}
  'tn!}
" d^#}
$ 
uU&')LL	M%}
 }
 }
 nm BA}
 }
 }
 }
 }
r5   r-  )Hr   r  r   typingr   r   r   r   r,   r   torch.nnr   r	   r
   activationsr   cache_utilsr   r   r   r   
generationr   modeling_attn_mask_utilsr   modeling_outputsr   r   r   r   r   r   r   modeling_utilsr   utilsr   r   r   r   r   r    r!   r"   configuration_umt5r$   
get_loggerrE   r   r  _CHECKPOINT_FOR_DOCModuler&   rK   rd   rl   rv   r   r   r   r  r  rM  UMT5_START_DOCSTRINGr  r  r*  r+  r,  r  r3  r-  rK  r5   r4   <module>rN     s       / / / / / / / / / / / /        A A A A A A A A A A ! ! ! ! ! ! P P P P P P P P P P P P ) ) ) ) ) ) > > > > > >                  . - - - - -	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 + * * * * * 
	H	%	%) + + + + +BI + + +4    	   .    RY   <    ")   $9 9 9 9 9BI 9 9 9D    RY   8    bi   <I I I I I	 I I IZ    RY   $t! t! t! t! t!/ t! t! t!nU U U U U# U U Up
 *^ @#! L d k
 k
 k
 k
 k
# k
 k
	 k
\ NPdeeU U U U U#6 U U feUp n c c c c c* c c	 cL   |
 |
 |
 |
 |
$7 |
 |
 |
~   A
 A
 A
 A
 A
!4 A
 A
 A
H   r
 r
 r
 r
 r
2 r
 r
 r
 r
 r
r5   