U
    5Af8                    @  s  d Z ddlmZ ddlZddlZddlmZmZmZ ddl	Z
ddl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mZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ dd	l%m&Z&m'Z'm(Z( dd
l)m*Z*m+Z+m,Z,m-Z- ddl.m/Z/ e-0e1Z2dZ3dZ4G dd de"j5j6Z7G dd de"j5j6Z8G dd de"j5j6Z9G dd de"j5j6Z:G dd de"j5j6Z;G dd de"j5j6Z<G dd de"j5j6Z=G dd de"j5j6Z>G dd  d e"j5j6Z?e#G d!d" d"e"j5j6Z@G d#d$ d$eZAd%ZBd&ZCe+d'eBG d(d) d)eAZDG d*d+ d+e"j5j6ZEe+d,eBG d-d. d.eAeZFG d/d0 d0eAeZGG d1d2 d2e"j5j6ZHe+d3eBG d4d5 d5eAeZIe+d6eBG d7d8 d8eAeZJe+d9eBG d:d; d;eAe ZKe+d<eBG d=d> d>eAeZLdS )?zTF 2.0 RoBERTa model.    )annotationsN)OptionalTupleUnion   )get_tf_activation)+TFBaseModelOutputWithPastAndCrossAttentions.TFBaseModelOutputWithPoolingAndCrossAttentions#TFCausalLMOutputWithCrossAttentionsTFMaskedLMOutputTFMultipleChoiceModelOutputTFQuestionAnsweringModelOutputTFSequenceClassifierOutputTFTokenClassifierOutput)TFCausalLanguageModelingLossTFMaskedLanguageModelingLossTFModelInputTypeTFMultipleChoiceLossTFPreTrainedModelTFQuestionAnsweringLossTFSequenceClassificationLossTFTokenClassificationLossget_initializerkeraskeras_serializableunpack_inputs)check_embeddings_within_bounds
shape_liststable_softmax)add_code_sample_docstringsadd_start_docstrings%add_start_docstrings_to_model_forwardlogging   )RobertaConfigzFacebookAI/roberta-baser$   c                      s>   e Zd ZdZ fddZdddZddd	ZdddZ  ZS )TFRobertaEmbeddingszV
    Same as BertEmbeddings with a tiny tweak for positional embeddings indexing.
    c                   s\   t  jf | d| _|| _|j| _|j| _|j| _tjj	|j
dd| _tjj|jd| _d S )Nr#   	LayerNormepsilonnameZrate)super__init__padding_idxconfighidden_sizemax_position_embeddingsinitializer_ranger   layersLayerNormalizationlayer_norm_epsr&   Dropouthidden_dropout_probdropoutselfr.   kwargs	__class__ S/tmp/pip-unpacked-wheel-zw5xktn0/transformers/models/roberta/modeling_tf_roberta.pyr,   I   s    zTFRobertaEmbeddings.__init__Nc              	   C  s   t d( | jd| jj| jgt| jd| _W 5 Q R X t d( | jd| jj	| jgt| jd| _
W 5 Q R X t d& | jd| j| jgt| jd| _W 5 Q R X | jrd S d| _t| dd d k	rt | jj | jd d | jjg W 5 Q R X d S )	NZword_embeddingsweight)r)   shapeinitializertoken_type_embeddings
embeddingsposition_embeddingsTr&   )tf
name_scope
add_weightr.   
vocab_sizer/   r   r1   r?   Ztype_vocab_sizerB   r0   rD   builtgetattrr&   r)   buildr9   input_shaper=   r=   r>   rK   T   s0    
zTFRobertaEmbeddings.buildr   c                 C  s>   t jt j|| j|jd}t jj|dd| | }|| j S )a  
        Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding
        symbols are ignored. This is modified from fairseq's `utils.make_positions`.

        Args:
            input_ids: tf.Tensor
        Returns: tf.Tensor
        dtyper#   axis)rE   castmath	not_equalr-   rO   Zcumsum)r9   	input_idspast_key_values_lengthmaskZincremental_indicesr=   r=   r>   "create_position_ids_from_input_idsq   s    	z6TFRobertaEmbeddings.create_position_ids_from_input_idsFc                 C  s   |dkr|dkrt |dk	r:t|| jj tj| j|d}t|dd }|dkr`tj|dd}|dkr|dk	r| j	||d}n,tj
tj| jd |d | j d ddd	}tj| j|d}tj| j|d}	|| |	 }
| j|
d
}
| j|
|d}
|
S )z
        Applies embedding based on inputs tensor.

        Returns:
            final_embeddings (`tf.Tensor`): output embedding tensor.
        N)paramsindicesr   Zdimsvalue)rU   rV   r#   )startlimitrP   inputsra   training)AssertionErrorr   r.   rH   rE   Zgatherr?   r   fillrX   Zexpand_dimsranger-   rD   rB   r&   r7   )r9   rU   position_idstoken_type_idsinputs_embedsrV   rc   rM   Zposition_embedsZtoken_type_embedsZfinal_embeddingsr=   r=   r>   call   s.       zTFRobertaEmbeddings.call)N)r   )NNNNr   F)	__name__
__module____qualname____doc__r,   rK   rX   rj   __classcell__r=   r=   r;   r>   r%   D   s   

      r%   c                      s<   e Zd Zdd fddZdddddZdd
dZ  ZS )TFRobertaPoolerr$   r.   c                   s6   t  jf | tjj|jt|jddd| _|| _	d S )Ntanhdense)unitskernel_initializer
activationr)   )
r+   r,   r   r2   Denser/   r   r1   rs   r.   r8   r;   r=   r>   r,      s    zTFRobertaPooler.__init__	tf.Tensorhidden_statesreturnc                 C  s    |d d df }| j |d}|S )Nr   r`   )rs   )r9   rz   Zfirst_token_tensorpooled_outputr=   r=   r>   rj      s    zTFRobertaPooler.callNc              	   C  sT   | j r
d S d| _ t| dd d k	rPt| jj | jd d | jjg W 5 Q R X d S NTrs   	rI   rJ   rE   rF   rs   r)   rK   r.   r/   rL   r=   r=   r>   rK      s    zTFRobertaPooler.build)Nrk   rl   rm   r,   rj   rK   ro   r=   r=   r;   r>   rp      s   rp   c                      s^   e Zd Zdd fddZdddddd	Zddddddddddd	ddZdddZ  ZS )TFRobertaSelfAttentionr$   rq   c                   s   t  jf | |j|j dkr8td|j d|j d|j| _t|j|j | _| j| j | _t	| j| _
tjj| jt|jdd| _tjj| jt|jdd| _tjj| jt|jdd| _tjj|jd	| _|j| _|| _d S )
Nr   zThe hidden size (z6) is not a multiple of the number of attention heads ()queryrt   ru   r)   keyr]   r*   )r+   r,   r/   num_attention_heads
ValueErrorintattention_head_sizeall_head_sizerS   sqrtsqrt_att_head_sizer   r2   rw   r   r1   r   r   r]   r5   Zattention_probs_dropout_probr7   
is_decoderr.   r8   r;   r=   r>   r,      s6          zTFRobertaSelfAttention.__init__rx   r   )tensor
batch_sizer{   c                 C  s0   t j||d| j| jfd}t j|ddddgdS )Nr[   r   r@   r      r#   r   perm)rE   reshaper   r   	transpose)r9   r   r   r=   r=   r>   transpose_for_scores   s    z+TFRobertaSelfAttention.transpose_for_scoresFTuple[tf.Tensor]bool	rz   attention_mask	head_maskencoder_hidden_statesencoder_attention_maskpast_key_valueoutput_attentionsrc   r{   c	                 C  s  t |d }	| j|d}
|d k	}|rB|d k	rB|d }|d }|}n|rt| | j|d|	}| | j|d|	}|}n|d k	r| | j|d|	}| | j|d|	}tj|d |gdd}tj|d |gdd}n(| | j|d|	}| | j|d|	}| |
|	}| jr||f}tj||dd}tj	| j
|jd}t||}|d k	rZt||}t|d	d
}| j||d}|d k	rt||}t||}tj|ddddgd}tj||	d	| jfd}|r||fn|f}| jr||f }|S )Nr   r`   r#   r   rP   T)transpose_brN   r[   )logitsrQ   rb   r   r   r   )r   r   r   r   r]   rE   concatr   matmulrR   r   rO   divideaddr   r7   multiplyr   r   r   )r9   rz   r   r   r   r   r   r   rc   r   Zmixed_query_layerZis_cross_attentionZ	key_layerZvalue_layerZquery_layerZattention_scoresZdkZattention_probsattention_outputoutputsr=   r=   r>   rj      sJ    


zTFRobertaSelfAttention.callNc              	   C  s   | j r
d S d| _ t| dd d k	rPt| jj | jd d | jjg W 5 Q R X t| dd d k	rt| j	j | j	d d | jjg W 5 Q R X t| dd d k	rt| j
j | j
d d | jjg W 5 Q R X d S )NTr   r   r]   )rI   rJ   rE   rF   r   r)   rK   r.   r/   r   r]   rL   r=   r=   r>   rK   A  s      zTFRobertaSelfAttention.build)F)N)rk   rl   rm   r,   r   rj   rK   ro   r=   r=   r;   r>   r      s
     Qr   c                      sB   e Zd Zdd fddZddddddd	d
ZdddZ  ZS )TFRobertaSelfOutputr$   rq   c                   sZ   t  jf | tjj|jt|jdd| _tjj	|j
dd| _tjj|jd| _|| _d S Nrs   r   r&   r'   r*   r+   r,   r   r2   rw   r/   r   r1   rs   r3   r4   r&   r5   r6   r7   r.   r8   r;   r=   r>   r,   R  s      zTFRobertaSelfOutput.__init__Frx   r   rz   input_tensorrc   r{   c                 C  s.   | j |d}| j||d}| j|| d}|S Nr`   rb   rs   r7   r&   r9   rz   r   rc   r=   r=   r>   rj   \  s    zTFRobertaSelfOutput.callNc              	   C  s   | j r
d S d| _ t| dd d k	rPt| jj | jd d | jjg W 5 Q R X t| dd d k	rt| j	j | j	d d | jjg W 5 Q R X d S NTrs   r&   )
rI   rJ   rE   rF   rs   r)   rK   r.   r/   r&   rL   r=   r=   r>   rK   c  s     zTFRobertaSelfOutput.build)F)Nr   r=   r=   r;   r>   r   Q  s   
r   c                      sT   e Zd Zdd fddZdd Zddddddd	d
d
d	d	ddZdddZ  ZS )TFRobertaAttentionr$   rq   c                   s.   t  jf | t|dd| _t|dd| _d S )Nr9   r)   output)r+   r,   r   self_attentionr   dense_outputr8   r;   r=   r>   r,   q  s    zTFRobertaAttention.__init__c                 C  s   t d S NNotImplementedError)r9   Zheadsr=   r=   r>   prune_headsw  s    zTFRobertaAttention.prune_headsFrx   r   r   )	r   r   r   r   r   r   r   rc   r{   c	              
   C  sD   | j ||||||||d}	| j|	d ||d}
|
f|	dd   }|S )Nrz   r   r   r   r   r   r   rc   r   rz   r   rc   r#   )r   r   )r9   r   r   r   r   r   r   r   rc   Zself_outputsr   r   r=   r=   r>   rj   z  s"    
  zTFRobertaAttention.callNc              	   C  s   | j r
d S d| _ t| dd d k	rFt| jj | jd  W 5 Q R X t| dd d k	r|t| jj | jd  W 5 Q R X d S )NTr   r   )rI   rJ   rE   rF   r   r)   rK   r   rL   r=   r=   r>   rK     s    zTFRobertaAttention.build)F)N)rk   rl   rm   r,   r   rj   rK   ro   r=   r=   r;   r>   r   p  s
     r   c                      s<   e Zd Zdd fddZdddddZdd
dZ  ZS )TFRobertaIntermediater$   rq   c                   sV   t  jf | tjj|jt|jdd| _t	|j
trDt|j
| _n|j
| _|| _d S )Nrs   r   )r+   r,   r   r2   rw   intermediate_sizer   r1   rs   
isinstanceZ
hidden_actstrr   intermediate_act_fnr.   r8   r;   r=   r>   r,     s      zTFRobertaIntermediate.__init__rx   ry   c                 C  s   | j |d}| |}|S )Nr`   )rs   r   )r9   rz   r=   r=   r>   rj     s    
zTFRobertaIntermediate.callNc              	   C  sT   | j r
d S d| _ t| dd d k	rPt| jj | jd d | jjg W 5 Q R X d S r}   r~   rL   r=   r=   r>   rK     s    zTFRobertaIntermediate.build)Nr   r=   r=   r;   r>   r     s   r   c                      sB   e Zd Zdd fddZddddddd	d
ZdddZ  ZS )TFRobertaOutputr$   rq   c                   sZ   t  jf | tjj|jt|jdd| _tjj	|j
dd| _tjj|jd| _|| _d S r   r   r8   r;   r=   r>   r,     s      zTFRobertaOutput.__init__Frx   r   r   c                 C  s.   | j |d}| j||d}| j|| d}|S r   r   r   r=   r=   r>   rj     s    zTFRobertaOutput.callNc              	   C  s   | j r
d S d| _ t| dd d k	rPt| jj | jd d | jjg W 5 Q R X t| dd d k	rt| j	j | j	d d | jj
g W 5 Q R X d S r   )rI   rJ   rE   rF   rs   r)   rK   r.   r   r&   r/   rL   r=   r=   r>   rK     s     zTFRobertaOutput.build)F)Nr   r=   r=   r;   r>   r     s   
r   c                      sL   e Zd Zdd fddZdddddddd	d	d
d	ddZdddZ  ZS )TFRobertaLayerr$   rq   c                   st   t  jf | t|dd| _|j| _|j| _| jrT| jsFt|  dt|dd| _t|dd| _	t
|dd| _d S )N	attentionr   z> should be used as a decoder model if cross attention is addedcrossattentionintermediater   )r+   r,   r   r   r   add_cross_attentionr   r   r   r   r   bert_outputr8   r;   r=   r>   r,     s    zTFRobertaLayer.__init__Frx   tf.Tensor | NonezTuple[tf.Tensor] | Noner   r   r   c	              
   C  s$  |d k	r|d d nd }	| j |||d d |	||d}
|
d }| jrV|
dd }|
d }n|
dd  }d }| jr|d k	rt| dstd|  d|d k	r|d	d  nd }| j||||||||d}|d }||dd  }|d }|| }| j|d
}| j|||d}|f| }| jr ||f }|S )Nr   )r   r   r   r   r   r   r   rc   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`rz   r   )r   r   hasattrr   r   r   r   )r9   rz   r   r   r   r   r   r   rc   Zself_attn_past_key_valueZself_attention_outputsr   r   Zpresent_key_valueZcross_attn_present_key_valueZcross_attn_past_key_valueZcross_attention_outputsZintermediate_outputZlayer_outputr=   r=   r>   rj     s^    




  

zTFRobertaLayer.callNc              	   C  s   | j r
d S d| _ t| dd d k	rFt| jj | jd  W 5 Q R X t| dd d k	r|t| jj | jd  W 5 Q R X t| dd d k	rt| jj | jd  W 5 Q R X t| dd d k	rt| j	j | j	d  W 5 Q R X d S )NTr   r   r   r   )
rI   rJ   rE   rF   r   r)   rK   r   r   r   rL   r=   r=   r>   rK   6  s    zTFRobertaLayer.build)F)Nr   r=   r=   r;   r>   r     s     Gr   c                      sR   e Zd Zdd fddZdddddddd	d
d
d
d
ddddZdddZ  ZS )TFRobertaEncoderr$   rq   c                   s2   t  jf |  | _ fddt jD | _d S )Nc                   s   g | ]}t  d | dqS )zlayer_._r   )r   ).0irq   r=   r>   
<listcomp>M  s     z-TFRobertaEncoder.__init__.<locals>.<listcomp>)r+   r,   r.   rf   num_hidden_layerslayerr8   r;   rq   r>   r,   J  s    zTFRobertaEncoder.__init__Frx   r   zTuple[Tuple[tf.Tensor]] | NoneOptional[bool]r   zDUnion[TFBaseModelOutputWithPastAndCrossAttentions, Tuple[tf.Tensor]])rz   r   r   r   r   past_key_values	use_cacher   output_hidden_statesreturn_dictrc   r{   c                 C  s  |	rdnd }|rdnd }|r(| j jr(dnd }|r4dnd }t| jD ]\}}|	rX||f }|d k	rh|| nd }||||| |||||d}|d }|r||d f7 }|rB||d f }| j jrB|d k	rB||d f }qB|	r||f }|
stdd ||||fD S t|||||d	S )
Nr=   r   r   r[   r#   r   c                 s  s   | ]}|d k	r|V  qd S r   r=   )r   vr=   r=   r>   	<genexpr>  s     z(TFRobertaEncoder.call.<locals>.<genexpr>)last_hidden_stater   rz   
attentionscross_attentions)r.   r   	enumerater   tupler   )r9   rz   r   r   r   r   r   r   r   r   r   rc   Zall_hidden_statesZall_attentionsZall_cross_attentionsZnext_decoder_cacher   Zlayer_moduler   Zlayer_outputsr=   r=   r>   rj   O  sL    



zTFRobertaEncoder.callNc              
   C  sR   | j r
d S d| _ t| dd d k	rN| jD ]&}t|j |d  W 5 Q R X q&d S )NTr   )rI   rJ   r   rE   rF   r)   rK   )r9   rM   r   r=   r=   r>   rK     s    
zTFRobertaEncoder.build)F)Nr   r=   r=   r;   r>   r   I  s    &>r   c                      s   e Zd ZeZd fdd	ZddddZdd	d
dZdd Ze	dddddddddddddddddddZ
dddZ  ZS )TFRobertaMainLayerTc                   sz   t  jf | || _|j| _|j| _|j| _|j| _|j| _|j| _	t
|dd| _|rbt|ddnd | _t|dd| _d S )Nencoderr   poolerrC   )r+   r,   r.   r   r   r1   r   r   Zuse_return_dictr   r   r   rp   r   r%   rC   )r9   r.   add_pooling_layerr:   r;   r=   r>   r,     s    zTFRobertaMainLayer.__init__zkeras.layers.Layer)r{   c                 C  s   | j S r   )rC   r9   r=   r=   r>   get_input_embeddings  s    z'TFRobertaMainLayer.get_input_embeddingsztf.Variable)r]   c                 C  s   || j _t|d | j _d S Nr   )rC   r?   r   rH   r9   r]   r=   r=   r>   set_input_embeddings  s    z'TFRobertaMainLayer.set_input_embeddingsc                 C  s   t dS )z
        Prunes heads of the model. heads_to_prune: dict of {layer_num: list of heads to prune in this layer} See base
        class PreTrainedModel
        Nr   )r9   Zheads_to_pruner=   r=   r>   _prune_heads  s    zTFRobertaMainLayer._prune_headsNFTFModelInputType | Nonenp.ndarray | tf.Tensor | None4Optional[Tuple[Tuple[Union[np.ndarray, tf.Tensor]]]]r   r   zGUnion[TFBaseModelOutputWithPoolingAndCrossAttentions, Tuple[tf.Tensor]]rU   r   rh   rg   r   ri   r   r   r   r   r   r   r   rc   r{   c                  C  s<  | j jsd}
|d k	r&|d k	r&tdn4|d k	r8t|}n"|d k	rRt|d d }ntd|\}}|	d krd}d gt| jj }	nt|	d d d }|d krtj||| fdd}|d krtj|dd}| j	||||||d	}t|}|| }| jrt
|}tt|d d d d f ||df|d d d d f }tj||jd
}||d d d d d f  }t|}t||d d|d |d f}|	d d k	r|d d d d | d d d f }nt||d dd|d f}tj||jd
}tjd|jd
}tjd|jd
}tt|||}| jr|d k	rtj||jd
}tt|}|dkrp|d d d d d d d f }|dkr|d d d d d d f }d| d }nd }|d k	rtnd g| j j }| j||||||	|
||||d}|d }| jd k	r| j|dnd }|s ||f|dd   S t|||j|j|j|jdS )NFzDYou cannot specify both input_ids and inputs_embeds at the same timer[   z5You have to specify either input_ids or inputs_embedsr   r   r#   r\   )rU   rg   rh   ri   rV   rc   rN   r   g      ?g     r   )rz   r   r   r   r   r   r   r   r   r   rc   r   )r   Zpooler_outputr   rz   r   r   )r.   r   r   r   lenr   r   rE   re   rC   rf   Z
less_equalZtilerR   rO   r   Zconstantr   subtractr   r   r   r	   r   rz   r   r   ) r9   rU   r   rh   rg   r   ri   r   r   r   r   r   r   r   rc   rM   r   
seq_lengthrV   Zembedding_outputZattention_mask_shapeZmask_seq_lengthZseq_idsZcausal_maskZextended_attention_maskZone_cstZten_thousand_cstZnum_dims_encoder_attention_maskZencoder_extended_attention_maskZencoder_outputssequence_outputr|   r=   r=   r>   rj     s    


 $ 	



zTFRobertaMainLayer.callc              	   C  s   | j r
d S d| _ t| dd d k	rFt| jj | jd  W 5 Q R X t| dd d k	r|t| jj | jd  W 5 Q R X t| dd d k	rt| jj | jd  W 5 Q R X d S )NTr   r   rC   )	rI   rJ   rE   rF   r   r)   rK   r   rC   rL   r=   r=   r>   rK   [  s    zTFRobertaMainLayer.build)T)NNNNNNNNNNNNNF)N)rk   rl   rm   r$   config_classr,   r   r   r   r   rj   rK   ro   r=   r=   r;   r>   r     s.                 . r   c                   @  s   e Zd ZdZeZdZdS )TFRobertaPreTrainedModelz
    An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
    models.
    robertaN)rk   rl   rm   rn   r$   r   Zbase_model_prefixr=   r=   r=   r>   r   j  s   r   a}	  

    This model inherits from [`TFPreTrainedModel`]. 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 [keras.Model](https://www.tensorflow.org/api_docs/python/tf/keras/Model) subclass. Use it
    as a regular TF 2.0 Keras Model and refer to the TF 2.0 documentation for all matter related to general usage and
    behavior.

    <Tip>

    TensorFlow models and layers in `transformers` accept two formats as input:

    - having all inputs as keyword arguments (like PyTorch models), or
    - having all inputs as a list, tuple or dict in the first positional argument.

    The reason the second format is supported is that Keras methods prefer this format when passing inputs to models
    and layers. Because of this support, when using methods like `model.fit()` things should "just work" for you - just
    pass your inputs and labels in any format that `model.fit()` supports! If, however, you want to use the second
    format outside of Keras methods like `fit()` and `predict()`, such as when creating your own layers or models with
    the Keras `Functional` API, there are three possibilities you can use to gather all the input Tensors in the first
    positional argument:

    - a single Tensor with `input_ids` only and nothing else: `model(input_ids)`
    - a list of varying length with one or several input Tensors IN THE ORDER given in the docstring:
    `model([input_ids, attention_mask])` or `model([input_ids, attention_mask, token_type_ids])`
    - a dictionary with one or several input Tensors associated to the input names given in the docstring:
    `model({"input_ids": input_ids, "token_type_ids": token_type_ids})`

    Note that when creating models and layers with
    [subclassing](https://keras.io/guides/making_new_layers_and_models_via_subclassing/) then you don't need to worry
    about any of this, as you can just pass inputs like you would to any other Python function!

    </Tip>

    Parameters:
        config ([`RobertaConfig`]): 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 (`Numpy array` or `tf.Tensor` of shape `({0})`):
            Indices of input sequence tokens in the vocabulary.

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

            [What are input IDs?](../glossary#input-ids)
        attention_mask (`Numpy array` or `tf.Tensor` of shape `({0})`, *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)
        token_type_ids (`Numpy array` or `tf.Tensor` of shape `({0})`, *optional*):
            Segment token indices to indicate first and second portions of the inputs. Indices are selected in `[0,
            1]`:

            - 0 corresponds to a *sentence A* token,
            - 1 corresponds to a *sentence B* token.

            [What are token type IDs?](../glossary#token-type-ids)
        position_ids (`Numpy array` or `tf.Tensor` of shape `({0})`, *optional*):
            Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
            config.max_position_embeddings - 1]`.

            [What are position IDs?](../glossary#position-ids)
        head_mask (`Numpy array` or `tf.Tensor` 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 (`tf.Tensor` of shape `({0}, 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. This argument can be used only in eager mode, in graph mode the value in the
            config will be used instead.
        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. This argument can be used only in eager mode, in graph mode the value in the config will be
            used instead.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple. This argument can be used in
            eager mode, in graph mode the value will always be set to True.
        training (`bool`, *optional*, defaults to `False`):
            Whether or not to use the model in training mode (some modules like dropout modules have different
            behaviors between training and evaluation).
zaThe bare RoBERTa Model transformer outputting raw hidden-states without any specific head on top.c                      sr   e Zd Z fddZeeedee	e
eddddddddddd	d
d
d
d
d
ddddZdddZ  ZS )TFRobertaModelc                   s&   t  j|f|| t|dd| _d S )Nr   r   )r+   r,   r   r   r9   r.   ra   r:   r;   r=   r>   r,     s    zTFRobertaModel.__init__batch_size, sequence_length
checkpointoutput_typer   NFr   r   r   r   z<Union[Tuple, TFBaseModelOutputWithPoolingAndCrossAttentions]r   c                 C  s*   | j |||||||||	|
||||d}|S )a  
        encoder_hidden_states  (`tf.Tensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
            Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
            the model is configured as a decoder.
        encoder_attention_mask (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
            Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
            the cross-attention if the model is configured as a decoder. Mask values selected in `[0, 1]`:

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

        past_key_values (`Tuple[Tuple[tf.Tensor]]` of length `config.n_layers`)
            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)`.
        use_cache (`bool`, *optional*, defaults to `True`):
            If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
            `past_key_values`). Set to `False` during training, `True` during generation
        rU   r   rh   rg   r   ri   r   r   r   r   r   r   r   rc   )r   )r9   rU   r   rh   rg   r   ri   r   r   r   r   r   r   r   rc   r   r=   r=   r>   rj     s"    ,zTFRobertaModel.callc              	   C  sJ   | j r
d S d| _ t| dd d k	rFt| jj | jd  W 5 Q R X d S )NTr   )rI   rJ   rE   rF   r   r)   rK   rL   r=   r=   r>   rK     s    zTFRobertaModel.build)NNNNNNNNNNNNNF)N)rk   rl   rm   r,   r   r!   ROBERTA_INPUTS_DOCSTRINGformatr   _CHECKPOINT_FOR_DOCr	   _CONFIG_FOR_DOCrj   rK   ro   r=   r=   r;   r>   r     s0                 28r   c                      sR   e Zd ZdZ fddZdddZdd Zd	d
 Zdd Zdd Z	dd Z
  ZS )TFRobertaLMHeadz*Roberta Head for masked language modeling.c                   s`   t  jf | || _|j| _tjj|jt|jdd| _	tjj
|jdd| _td| _|| _d S )Nrs   ru   r)   
layer_normr'   Zgelu)r+   r,   r.   r/   r   r2   rw   r   r1   rs   r3   r4   r   r   actdecoder)r9   r.   input_embeddingsr:   r;   r=   r>   r,   *  s      
zTFRobertaLMHead.__init__Nc              	   C  s   | j | jjfdddd| _| jr$d S d| _t| dd d k	rjt| jj	 | j
d d | jjg W 5 Q R X t| dd d k	rt| jj	 | j
d d | jjg W 5 Q R X d S )NzerosTbias)r@   rA   Z	trainabler)   rs   r   )rG   r.   rH   r  rI   rJ   rE   rF   rs   r)   rK   r/   r   rL   r=   r=   r>   rK   9  s     zTFRobertaLMHead.buildc                 C  s   | j S r   )r  r   r=   r=   r>   get_output_embeddingsF  s    z%TFRobertaLMHead.get_output_embeddingsc                 C  s   || j _t|d | j _d S r   )r  r?   r   rH   r   r=   r=   r>   set_output_embeddingsI  s    z%TFRobertaLMHead.set_output_embeddingsc                 C  s
   d| j iS )Nr  )r  r   r=   r=   r>   get_biasM  s    zTFRobertaLMHead.get_biasc                 C  s"   |d | _ t|d d | j_d S )Nr  r   )r  r   r.   rH   r   r=   r=   r>   set_biasP  s    
zTFRobertaLMHead.set_biasc                 C  s   |  |}| |}| |}t|dd }tj|d| jgd}tj|| jj	dd}tj|d|| j
jgd}tjj|| jd}|S )N)r   r#   r[   r   T)abr   )r]   r  )rs   r  r   r   rE   r   r/   r   r  r?   r.   rH   nnZbias_addr  )r9   rz   r   r=   r=   r>   rj   T  s    


zTFRobertaLMHead.call)N)rk   rl   rm   rn   r,   rK   r  r  r  r	  rj   ro   r=   r=   r;   r>   r   '  s   
r   z5RoBERTa Model with a `language modeling` head on top.c                      s   e Zd ZddgZ fddZdd Zdd Zeee	
d	eeeed
dddddddddddddddddddZdddZ  ZS )TFRobertaForMaskedLMr   lm_head.decoder.weightc                   s<   t  j|f|| t|ddd| _t|| jjdd| _d S )NFr   r   r)   lm_headr   )r+   r,   r   r   r   rC   r  r   r;   r=   r>   r,   h  s    zTFRobertaForMaskedLM.__init__c                 C  s   | j S r   r  r   r=   r=   r>   get_lm_headn  s    z TFRobertaForMaskedLM.get_lm_headc                 C  s   t dt | jd | jj S NzMThe method get_prefix_bias_name is deprecated. Please use `get_bias` instead./warningswarnFutureWarningr)   r  r   r=   r=   r>   get_prefix_bias_nameq  s    z)TFRobertaForMaskedLM.get_prefix_bias_namer   z<mask>z' Paris'g?)r   r   r   rW   expected_outputexpected_lossNFr   r   r   z)Union[TFMaskedLMOutput, Tuple[tf.Tensor]]rU   r   rh   rg   r   ri   r   r   r   labelsrc   r{   c                 C  s   | j |||||||||	|d
}|d }| |}|
dkr<dn
| |
|}|	st|f|dd  }|dk	rp|f| S |S t|||j|jdS )a  
        labels (`tf.Tensor` 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]`
        	r   rh   rg   r   ri   r   r   r   rc   r   Nr   lossr   rz   r   )r   r  hf_compute_lossr   rz   r   )r9   rU   r   rh   rg   r   ri   r   r   r   r  rc   r   r   Zprediction_scoresr   r   r=   r=   r>   rj   u  s0    
zTFRobertaForMaskedLM.callc              	   C  s   | j r
d S d| _ t| dd d k	rFt| jj | jd  W 5 Q R X t| dd d k	r|t| jj | jd  W 5 Q R X d S NTr   r  rI   rJ   rE   rF   r   r)   rK   r  rL   r=   r=   r>   rK     s    zTFRobertaForMaskedLM.build)NNNNNNNNNNF)N)rk   rl   rm   "_keys_to_ignore_on_load_unexpectedr,   r  r  r   r!   r   r   r   r   r   r   rj   rK   ro   r=   r=   r;   r>   r  c  s6   
           ,1r  c                      s   e Zd ZddgZdd fddZdd Zd	d
 ZdddZee	e
deeeedddddddddddddddddddddZdddZ  ZS )TFRobertaForCausalLMr   r  r$   rq   c                   sL   t  j|f|| |js$td t|ddd| _t|| jjdd| _	d S )NzQIf you want to use `TFRobertaLMHeadModel` as a standalone, add `is_decoder=True.`Fr   r  r  )r  r)   )
r+   r,   r   loggerwarningr   r   r   rC   r  r   r;   r=   r>   r,     s
    
zTFRobertaForCausalLM.__init__c                 C  s   | j S r   r  r   r=   r=   r>   r    s    z TFRobertaForCausalLM.get_lm_headc                 C  s   t dt | jd | jj S r  r  r   r=   r=   r>   r    s    z)TFRobertaForCausalLM.get_prefix_bias_nameNc                 K  s@   |j }|d krt|}|d k	r4|d d dd f }|||dS )Nr[   )rU   r   r   )r@   rE   Zones)r9   rU   r   r   Zmodel_kwargsrM   r=   r=   r>   prepare_inputs_for_generation  s    
z2TFRobertaForCausalLM.prepare_inputs_for_generationr   r   Fr   r   r   r   z<Union[TFCausalLMOutputWithCrossAttentions, Tuple[tf.Tensor]])rU   r   rh   rg   r   ri   r   r   r   r   r   r   r   r  rc   r{   c                 C  s   | j |||||||||	|
||||d}|d }| j||d}d}|dk	r~|ddddf }|ddddf }| j||d}|s|f|dd  }|dk	r|f| S |S t|||j|j|j|jd	S )
a  
        encoder_hidden_states  (`tf.Tensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
            Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention if
            the model is configured as a decoder.
        encoder_attention_mask (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
            Mask to avoid performing attention on the padding token indices of the encoder input. This mask is used in
            the cross-attention if the model is configured as a decoder. Mask values selected in `[0, 1]`:

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

        past_key_values (`Tuple[Tuple[tf.Tensor]]` of length `config.n_layers`)
            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)`.
        use_cache (`bool`, *optional*, defaults to `True`):
            If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
            `past_key_values`). Set to `False` during training, `True` during generation
        labels (`tf.Tensor` or `np.ndarray` of shape `(batch_size, sequence_length)`, *optional*):
            Labels for computing the cross entropy classification loss. Indices should be in `[0, ...,
            config.vocab_size - 1]`.
        r   r   )rz   rc   Nr[   r#   )r  r   r   )r   r   r   rz   r   r   )r   r  r!  r
   r   rz   r   r   )r9   rU   r   rh   rg   r   ri   r   r   r   r   r   r   r   r  rc   r   r   r   r   Zshifted_logitsr   r=   r=   r>   rj     sD    0zTFRobertaForCausalLM.callc              	   C  s   | j r
d S d| _ t| dd d k	rFt| jj | jd  W 5 Q R X t| dd d k	r|t| jj | jd  W 5 Q R X d S r"  r#  rL   r=   r=   r>   rK   5  s    zTFRobertaForCausalLM.build)NN)NNNNNNNNNNNNNNF)N)rk   rl   rm   r$  r,   r  r  r(  r   r!   r   r   r   r   r
   r   rj   rK   ro   r=   r=   r;   r>   r%    s:   	
               4Qr%  c                      s4   e Zd ZdZ fddZd
ddZddd	Z  ZS )TFRobertaClassificationHeadz-Head for sentence-level classification tasks.c                   sv   t  jf | tjj|jt|jddd| _|j	d k	r<|j	n|j
}tj|| _tjj|jt|jdd| _|| _d S )Nrr   rs   )ru   rv   r)   out_projr   )r+   r,   r   r2   rw   r/   r   r1   rs   classifier_dropoutr6   r5   r7   
num_labelsr*  r.   )r9   r.   r:   r+  r;   r=   r>   r,   D  s       z$TFRobertaClassificationHead.__init__Fc                 C  sJ   |d d dd d f }| j ||d}| |}| j ||d}| |}|S )Nr   rc   )r7   rs   r*  )r9   featuresrc   xr=   r=   r>   rj   U  s    

z TFRobertaClassificationHead.callNc              	   C  s   | j r
d S d| _ t| dd d k	rPt| jj | jd d | jjg W 5 Q R X t| dd d k	rt| j	j | j	d d | jjg W 5 Q R X d S )NTrs   r*  )
rI   rJ   rE   rF   rs   r)   rK   r.   r/   r*  rL   r=   r=   r>   rK   ]  s     z!TFRobertaClassificationHead.build)F)N)rk   rl   rm   rn   r,   rj   rK   ro   r=   r=   r;   r>   r)  A  s   
r)  z
    RoBERTa Model transformer with a sequence classification/regression head on top (a linear layer on top of the
    pooled output) e.g. for GLUE tasks.
    c                      sx   e Zd ZddgZ fddZeeede	de
eddd	ddddddddddddddddZdddZ  ZS )"TFRobertaForSequenceClassificationr   r  c                   s>   t  j|f|| |j| _t|ddd| _t|dd| _d S )NFr   r  
classifierr   )r+   r,   r,  r   r   r)  r1  r   r;   r=   r>   r,   t  s    z+TFRobertaForSequenceClassification.__init__r   z'cardiffnlp/twitter-roberta-base-emotionz
'optimism'g{Gz?r   r   r   r  r  NFr   r   r   z3Union[TFSequenceClassifierOutput, Tuple[tf.Tensor]]r  c                 C  s   | j |||||||||	|d
}|d }| j||d}|
dkr@dn
| |
|}|	sx|f|dd  }|dk	rt|f| S |S t|||j|jdS )a  
        labels (`tf.Tensor` 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).
        r  r   r-  Nr   r  )r   r1  r!  r   rz   r   r9   rU   r   rh   rg   r   ri   r   r   r   r  rc   r   r   r   r   r   r=   r=   r>   rj   {  s0    z'TFRobertaForSequenceClassification.callc              	   C  s   | j r
d S d| _ t| dd d k	rFt| jj | jd  W 5 Q R X t| dd d k	r|t| jj | jd  W 5 Q R X d S NTr   r1  )rI   rJ   rE   rF   r   r)   rK   r1  rL   r=   r=   r>   rK     s    z(TFRobertaForSequenceClassification.build)NNNNNNNNNNF)N)rk   rl   rm   r$  r,   r   r!   r   r   r   r   r   rj   rK   ro   r=   r=   r;   r>   r0  i  s0   		           ,0r0  z
    Roberta Model with a multiple choice classification head on top (a linear layer on top of the pooled output and a
    softmax) e.g. for RocStories/SWAG tasks.
    c                      sx   e Zd ZdgZdgZ fddZeee	de
eeeddd	d
d
d
d
d
dddd
dddddZdddZ  ZS )TFRobertaForMultipleChoicer  r7   c                   sV   t  j|f|| t|dd| _tj|j| _tjj	dt
|jdd| _|| _d S )Nr   r   r#   r1  r   )r+   r,   r   r   r   r2   r5   r6   r7   rw   r   r1   r1  r.   r   r;   r=   r>   r,     s      z#TFRobertaForMultipleChoice.__init__z(batch_size, num_choices, sequence_lengthr   NFr   r   r   z4Union[TFMultipleChoiceModelOutput, Tuple[tf.Tensor]]r  c                 C  sV  |dk	r"t |d }t |d }nt |d }t |d }|dk	rRt|d|fnd}|dk	rnt|d|fnd}|dk	rt|d|fnd}|dk	rt|d|fnd}| j|||||||||	|d
}|d }| j||d}| |}t|d|f}|
dkrdn
| |
|}|	sB|f|dd  }|dk	r>|f| S |S t|||j|j	dS )a5  
        labels (`tf.Tensor` of shape `(batch_size,)`, *optional*):
            Labels for computing the multiple choice classification loss. Indices should be in `[0, ..., num_choices]`
            where `num_choices` is the size of the second dimension of the input tensors. (See `input_ids` above)
        Nr#   r   r[   )r   rc   r-  r  )
r   rE   r   r   r7   r1  r!  r   rz   r   )r9   rU   r   rh   rg   r   ri   r   r   r   r  rc   Znum_choicesr   Zflat_input_idsZflat_attention_maskZflat_token_type_idsZflat_position_idsr   r|   r   Zreshaped_logitsr   r   r=   r=   r>   rj     sF    
zTFRobertaForMultipleChoice.callc              	   C  s   | j r
d S d| _ t| dd d k	rFt| jj | jd  W 5 Q R X t| dd d k	rt| jj | jd d | jj	g W 5 Q R X d S r4  
rI   rJ   rE   rF   r   r)   rK   r1  r.   r/   rL   r=   r=   r>   rK     s    z TFRobertaForMultipleChoice.build)NNNNNNNNNNF)N)rk   rl   rm   r$  _keys_to_ignore_on_load_missingr,   r   r!   r   r   r   r   r   r   rj   rK   ro   r=   r=   r;   r>   r5    s.   	
           ,=r5  z
    RoBERTa 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                      s~   e Zd ZddgZdgZ fddZeee	de
deedd	d
ddddddddddddddddZdddZ  ZS )TFRobertaForTokenClassificationr   r  r7   c                   sv   t  j|f|| |j| _t|ddd| _|jd k	r<|jn|j}tj	|| _
tjj|jt|jdd| _|| _d S )NFr   r  r1  r   )r+   r,   r,  r   r   r+  r6   r   r2   r5   r7   rw   r   r1   r1  r.   )r9   r.   ra   r:   r+  r;   r=   r>   r,   2  s      z(TFRobertaForTokenClassification.__init__r   z!ydshieh/roberta-large-ner-englishzF['O', 'ORG', 'ORG', 'O', 'O', 'O', 'O', 'O', 'LOC', 'O', 'LOC', 'LOC']g{Gz?r2  NFr   r   r   z0Union[TFTokenClassifierOutput, Tuple[tf.Tensor]]r  c                 C  s   | j |||||||||	|d
}|d }| j||d}| |}|
dkrJdn
| |
|}|	s|f|dd  }|dk	r~|f| S |S t|||j|jdS )z
        labels (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
            Labels for computing the token classification loss. Indices should be in `[0, ..., config.num_labels - 1]`.
        r  r   r-  Nr   r  )r   r7   r1  r!  r   rz   r   r3  r=   r=   r>   rj   @  s2    
z$TFRobertaForTokenClassification.callc              	   C  s   | j r
d S d| _ t| dd d k	rFt| jj | jd  W 5 Q R X t| dd d k	rt| jj | jd d | jj	g W 5 Q R X d S r4  r6  rL   r=   r=   r>   rK   y  s    z%TFRobertaForTokenClassification.build)NNNNNNNNNNF)N)rk   rl   rm   r$  r7  r,   r   r!   r   r   r   r   r   rj   rK   ro   r=   r=   r;   r>   r8  &  s2   		           ,0r8  z
    RoBERTa Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear
    layers on top of the hidden-states output to compute `span start logits` and `span end logits`).
    c                      sz   e Zd ZddgZ fddZeeede	de
eddd	dddddddddddddddddZdddZ  ZS )TFRobertaForQuestionAnsweringr   r  c                   sR   t  j|f|| |j| _t|ddd| _tjj|jt|j	dd| _
|| _d S )NFr   r  
qa_outputsr   )r+   r,   r,  r   r   r   r2   rw   r   r1   r:  r.   r   r;   r=   r>   r,     s      z&TFRobertaForQuestionAnswering.__init__r   zydshieh/roberta-base-squad2z	' puppet'gQ?r2  NFr   r   r   z7Union[TFQuestionAnsweringModelOutput, Tuple[tf.Tensor]])rU   r   rh   rg   r   ri   r   r   r   start_positionsend_positionsrc   r{   c                 C  s   | j |||||||||	|d
}|d }| |}tj|ddd\}}tj|dd}tj|dd}d}|
dk	r|dk	rd|
i}||d< | |||f}|	s||f|dd  }|dk	r|f| S |S t||||j|jd	S )
a  
        start_positions (`tf.Tensor` 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 (`tf.Tensor` 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.
        r  r   r   r[   rP   NZstart_positionZend_position)r   start_logits
end_logitsrz   r   )	r   r:  rE   splitZsqueezer!  r   rz   r   )r9   rU   r   rh   rg   r   ri   r   r   r   r;  r<  rc   r   r   r   r=  r>  r   r  r   r=   r=   r>   rj     s@    "
z"TFRobertaForQuestionAnswering.callc              	   C  s   | j r
d S d| _ t| dd d k	rFt| jj | jd  W 5 Q R X t| dd d k	rt| jj | jd d | jj	g W 5 Q R X d S )NTr   r:  )
rI   rJ   rE   rF   r   r)   rK   r:  r.   r/   rL   r=   r=   r>   rK     s    z#TFRobertaForQuestionAnswering.build)NNNNNNNNNNNF)N)rk   rl   rm   r$  r,   r   r!   r   r   r   r   r   rj   rK   ro   r=   r=   r;   r>   r9    s2   	
	            .>r9  )Mrn   
__future__r   rS   r  typingr   r   r   ZnumpynpZ
tensorflowrE   Zactivations_tfr   Zmodeling_tf_outputsr   r	   r
   r   r   r   r   r   Zmodeling_tf_utilsr   r   r   r   r   r   r   r   r   r   r   r   Ztf_utilsr   r   r   utilsr   r    r!   r"   Zconfiguration_robertar$   Z
get_loggerrk   r&  r   r   r2   ZLayerr%   rp   r   r   r   r   r   r   r   r   r   ZROBERTA_START_DOCSTRINGr   r   r   r  r%  r)  r0  r5  r8  r9  r=   r=   r=   r>   <module>   s|   (
8
j 4hN S
*8M<X (P_X