U
    ,-e                     @   sd  d 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 ddlmZmZmZ ddl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eZ dZ!dgZ"dd Z#dd Z$d(ddZ%G dd dej&Z'dd Z(G dd dej&Z)G dd deZ*dZ+dZ,ede+G d d! d!e*Z-ed"e+G d#d$ d$e*Z.ed%e+G d&d' d'e*Z/dS ))z PyTorch CTRL model.    )OptionalTupleUnionN)nn)BCEWithLogitsLossCrossEntropyLossMSELoss   )BaseModelOutputWithPastCausalLMOutputWithPastSequenceClassifierOutput)PreTrainedModel)Conv1D find_pruneable_heads_and_indicesprune_linear_layer)add_start_docstrings%add_start_docstrings_to_model_forwardloggingreplace_return_docstrings   )
CTRLConfigr   zSalesforce/ctrlc                 C   s$   dt dd|d  |  }| | S )Nr   i'     )torchpow)posid_model_sizeZangle_rates r   g/var/www/html/Darija-Ai-Train/env/lib/python3.8/site-packages/transformers/models/ctrl/modeling_ctrl.py
angle_defn*   s    r   c                 C   sz   t tj| |ddtj||dd|}t|d d dd df }t|d d dd df }tj||gdd}|S )Ndtyper   r   r   dim)r   r   arange	unsqueezesincoscat)positionr   r!   Z
angle_radsZsinesZcosinespos_encodingr   r   r   positional_encoding/   s    r,   c              	   C   s   t | |dddd}|jd }|t| }|d k	rn|d|d }	}
|||
|	 |
d |
f d 7 }|d k	r~|| }t j|dd}|d k	r|| }t ||}||fS )	Nr   r   r	   r   r"   g     r#   )r   matmulpermuteshapenpsqrtsizeZsoftmax)qkvmaskattention_mask	head_maskZ	matmul_qkZdkZscaled_attention_logitsndnsZattention_weightsoutputr   r   r   scaled_dot_product_attention>   s    
 r=   c                       s6   e Zd Z fddZdd Zdd Zdd	d
Z  ZS )MultiHeadAttentionc                    sj   t    || _|| _t|| j | _t||| _t||| _	t||| _
t||| _t | _d S N)super__init__	num_headsr   intdepthr   LinearWqWkWvdensesetpruned_heads)selfr   rB   	__class__r   r   rA   Y   s    
zMultiHeadAttention.__init__c                 C   s   | j | j }t|dkrd S t|| j|| j\}}t| j|| _t| j|| _t| j|| _t| j	|dd| _	| jt| | _|| j | _ | j
|| _d S )Nr   r   r#   )r   rB   lenr   rK   r   rF   rG   rH   rI   union)rL   headsZattention_head_sizeindexr   r   r   prune_headsg   s    zMultiHeadAttention.prune_headsc                 C   s&   | |d| j| j}|ddddgS )Nr"   r   r   r   r	   )reshaperB   rD   r/   )rL   x
batch_sizer   r   r   split_into_headsx   s    z#MultiHeadAttention.split_into_headsNFc
                 C   s  |j d }
| |}| |}| |}| ||
}| ||
}| ||
}|d k	r|d |d  }}tj||fdd}tj||fdd}|dkrt||f}nd}t||||||}|d 	ddddg}|d }|
|
d	| j}| |}||f}|	r||f }|S )
Nr   r   r-   r#   Tr?   r   r	   r"   )r0   rF   rG   rH   rW   r   r)   stackr=   r/   rT   r   rI   )rL   r6   r5   r4   r7   
layer_pastr8   r9   	use_cacheoutput_attentionsrV   Zpast_keyZ
past_valuepresentr<   Zscaled_attentionZattnZoriginal_size_attentionoutputsr   r   r   forward|   s.    





zMultiHeadAttention.forward)NNNFF)__name__
__module____qualname__rA   rS   rW   r^   __classcell__r   r   rM   r   r>   X   s   
     r>   c                 C   s"   t t | |t  t || S r?   )r   Z
SequentialrE   ZReLU)r   dffr   r   r   point_wise_feed_forward_network   s    rd   c                       s(   e Zd Zd fdd	Zd	ddZ  ZS )
EncoderLayer皙?c                    s^   t    t||| _t||| _tj|dd| _tj|dd| _	t
|| _t
|| _d S )Ngư>Zeps)r@   rA   r>   multi_head_attentionrd   ffnr   	LayerNorm
layernorm1
layernorm2Dropoutdropout1dropout2)rL   r   rB   rc   ZraterM   r   r   rA      s    
zEncoderLayer.__init__NFc                 C   s|   |  |}| j|||||||||d	}	|	d }
| |
}
||
 }| |}| |}| |}|| }|f|	dd   }|S )NrY   r8   r9   rZ   r[   r   r   )rk   rh   rn   rl   ri   ro   )rL   rU   r7   rY   r8   r9   rZ   r[   normedZattn_outputsZattn_outputZout1Zout2Z
ffn_outputr]   r   r   r   r^      s*    




zEncoderLayer.forward)rf   )NNNFF)r_   r`   ra   rA   r^   rb   r   r   rM   r   re      s            re   c                   @   s    e Zd ZdZeZdZdd ZdS )CTRLPreTrainedModelz
    An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained
    models.
    transformerc                 C   s   t |tjtfr>|jjjd| jjd |j	dk	r|j	j
  nft |tjr~|jjjd| jjd |jdk	r|jj|j 
  n&t |tjr|j	j
  |jjd dS )zInitialize the weights.g        )ZmeanZstdN      ?)
isinstancer   rE   r   weightdataZnormal_configZinitializer_rangebiasZzero_	EmbeddingZpadding_idxrj   Zfill_)rL   moduler   r   r   _init_weights   s    

z!CTRLPreTrainedModel._init_weightsN)r_   r`   ra   __doc__r   config_classZbase_model_prefixr|   r   r   r   r   rr      s   rr   a>  

    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 ([`CTRLConfig`]): 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)`):
            `input_ids_length` = `sequence_length` if `past_key_values` is `None` else `past_key_values[0].shape[-2]`
            (`sequence_length` of input past key value states). Indices of input sequence tokens in the vocabulary.

            If `past_key_values` is used, only input IDs that do not have their past calculated should be passed as
            `input_ids`.

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

            [What are input IDs?](../glossary#input-ids)
        past_key_values (`Tuple[Tuple[torch.FloatTensor]]` of length `config.n_layers`):
            Contains pre-computed hidden-states (key and values in the attention blocks) as computed by the model (see
            `past_key_values` output below). Can be used to speed up sequential decoding. The `input_ids` which have
            their past given to this model should not be passed as input ids as they have already been computed.
        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)
        token_type_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *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 (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *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 (`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.
        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.
z^The bare CTRL Model transformer outputting raw hidden-states without any specific head on top.c                       s   e Zd Z fddZdd Zdd Zdd Zeee	e
ed	deej eeeej   eej eej eej eej eej ee ee ee ee eeej e
f dddZ  ZS )	CTRLModelc                    s   t     j| _ j| _t j| jtj	| _
t j j| _t j| _t fddt jD | _tj j jd| _|   d S )Nc                    s"   g | ]}t  j j j jqS r   )re   n_embdZn_headrc   Zresid_pdrop).0_rx   r   r   
<listcomp>L  s     z&CTRLModel.__init__.<locals>.<listcomp>rg   )r@   rA   r   r   n_layerZ
num_layersr,   Zn_positionsr   floatr+   r   rz   
vocab_sizewrm   Z
embd_pdropdropoutZ
ModuleListrangehrj   Zlayer_norm_epsilon	layernorm	post_initrL   rx   rM   r   r   rA   @  s    zCTRLModel.__init__c                 C   s   | j S r?   r   rL   r   r   r   get_input_embeddingsS  s    zCTRLModel.get_input_embeddingsc                 C   s
   || _ d S r?   r   rL   Znew_embeddingsr   r   r   set_input_embeddingsV  s    zCTRLModel.set_input_embeddingsc                 C   s(   |  D ]\}}| j| j| qdS )zv
        Prunes heads of the model. heads_to_prune: dict of {layer_num: list of heads to prune in this layer}
        N)itemsr   rh   rS   )rL   Zheads_to_prunelayerrQ   r   r   r   _prune_headsY  s    zCTRLModel._prune_headsoutput_typer~   N)	input_idspast_key_valuesr8   token_type_idsposition_idsr9   inputs_embedsrZ   r[   output_hidden_statesreturn_dictreturnc              
   C   s  |	dk	r|	n| j j}	|dk	r |n| j j}|
dk	r4|
n| j j}
|dk	rH|n| j j}|dk	rj|dk	rjtdnd|dk	r| || | }|d|d }|j	d }n,|dk	r| dd }|j	d }ntd|dk	r|j
n|j
}|dkrd}tdgt| j }n|d d d}|dkrTtj||d | tj|d}|dd|d }|dk	r|dkrptd||d}|d	d
}|j| jd}d| t| jj }| || j j}|dk	r|d|d }| |}|t| j9 }nd}|d|d }|dkr| |}|d }tt|| || d	|}|t| j9 }| j|| _| j|ddf }|| | }| |}|rdnd}|
rdnd}|	rdnd}t t!| j|D ]p\}\}}|
r||f }||||||| ||	d}|dd
 \}}|dkr"||f }|	r||d
 f7 }q| "|}|
rT||f }|sttdd ||||fD S t#||||dS )a  
        Returns:

        Example:

        ```python
        >>> from transformers import AutoTokenizer, CTRLModel
        >>> import torch

        >>> tokenizer = AutoTokenizer.from_pretrained("Salesforce/ctrl")
        >>> model = CTRLModel.from_pretrained("Salesforce/ctrl")

        >>> # CTRL was trained with control codes as the first token
        >>> inputs = tokenizer("Opinion My dog is cute", return_tensors="pt")
        >>> assert inputs["input_ids"][0, 0].item() in tokenizer.control_codes.values()

        >>> outputs = model(**inputs)

        >>> last_hidden_states = outputs.last_hidden_state
        >>> list(last_hidden_states.shape)
        [1, 5, 1280]
        ```NzDYou cannot specify both input_ids and inputs_embeds at the same timer"   r   z5You have to specify either input_ids or inputs_embedsr-   )r!   devicez$batch_size has to be defined and > 0r   r   r    rt   r   rp   Tc                 s   s   | ]}|d k	r|V  qd S r?   r   )r   r6   r   r   r   	<genexpr>  s      z$CTRLModel.forward.<locals>.<genexpr>)Zlast_hidden_stater   hidden_states
attentions)$rx   r[   rZ   r   use_return_dict
ValueErrorZ%warn_if_padding_and_no_attention_maskr3   viewr0   r   tuplerO   r   r   r%   longr&   tor!   ZfinfominZget_head_maskr   r   r1   r2   r   ZtriuZonesr+   r   	enumeratezipr   r
   )rL   r   r   r8   r   r   r9   r   rZ   r[   r   r   Zinput_shaperV   r   Zpast_lengthZtoken_type_embedsZseq_lenr7   Z
pos_embedsr   ZpresentsZall_hidden_statesZall_attentionsr   r   rY   r]   r\   r   r   r   r^   `  s    &








"

	



zCTRLModel.forward)NNNNNNNNNNN)r_   r`   ra   rA   r   r   r   r   CTRL_INPUTS_DOCSTRINGr   r
   _CONFIG_FOR_DOCr   r   
LongTensorr   FloatTensorboolr   Tensorr^   rb   r   r   rM   r   r   ;  s>   
           r   z
    The CTRL Model transformer with a language modeling head on top (linear layer with weights tied to the input
    embeddings).
    c                       s   e Zd ZdgZ fddZdd Zdd Zdd	d
Zee	e
eeddeej eeeej   eej eej eej eej eej eej ee ee ee ee eeej ef dddZeeeej  ejeeej  dddZ  ZS )CTRLLMHeadModelzlm_head.weightc                    s8   t  | t|| _tj|j|jdd| _| 	  d S )NTry   )
r@   rA   r   rs   r   rE   r   r   lm_headr   r   rM   r   r   rA     s    
zCTRLLMHeadModel.__init__c                 C   s   | j S r?   r   r   r   r   r   get_output_embeddings  s    z%CTRLLMHeadModel.get_output_embeddingsc                 C   s
   || _ d S r?   r   r   r   r   r   set_output_embeddings  s    z%CTRLLMHeadModel.set_output_embeddingsNc                 K   s&   |r|d d df  d}|||dS )Nr"   )r   r   rZ   )r&   )rL   r   r   rZ   kwargsr   r   r   prepare_inputs_for_generation  s    z-CTRLLMHeadModel.prepare_inputs_for_generationr   r   r   r8   r   r   r9   r   labelsrZ   r[   r   r   r   c                 C   s   |dk	r|n| j j}| j||||||||	|
||d}|d }| |}d}|dk	r|dddddf  }|dddf  }t }||d|d|d}|s|f|dd  }|dk	r|f| S |S t|||j	|j
|jdS )ay  
        labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
            Labels for language modeling. Note that the labels **are shifted** inside the model, i.e. you can set
            `labels = input_ids` Indices are selected in `[-100, 0, ..., config.vocab_size]` All labels set to `-100`
            are ignored (masked), the loss is only computed for labels in `[0, ..., config.vocab_size]`

        Returns:

        Example:

        ```python
        >>> import torch
        >>> from transformers import AutoTokenizer, CTRLLMHeadModel

        >>> tokenizer = AutoTokenizer.from_pretrained("Salesforce/ctrl")
        >>> model = CTRLLMHeadModel.from_pretrained("Salesforce/ctrl")

        >>> # CTRL was trained with control codes as the first token
        >>> inputs = tokenizer("Wikipedia The llama is", return_tensors="pt")
        >>> assert inputs["input_ids"][0, 0].item() in tokenizer.control_codes.values()

        >>> sequence_ids = model.generate(inputs["input_ids"])
        >>> sequences = tokenizer.batch_decode(sequence_ids)
        >>> sequences
        ['Wikipedia The llama is a member of the family Bovidae. It is native to the Andes of Peru,']

        >>> outputs = model(**inputs, labels=inputs["input_ids"])
        >>> round(outputs.loss.item(), 2)
        9.21

        >>> list(outputs.logits.shape)
        [1, 5, 246534]
        ```N
r   r8   r   r   r9   r   rZ   r[   r   r   r   .r"   r   )losslogitsr   r   r   )rx   r   rs   r   
contiguousr   r   r3   r   r   r   r   )rL   r   r   r8   r   r   r9   r   r   rZ   r[   r   r   transformer_outputsr   Z	lm_logitsr   Zshift_logitsZshift_labelsloss_fctr<   r   r   r   r^     s@    2
zCTRLLMHeadModel.forward)r   beam_idxr   c                    s   t  fdd| D S )a  
        This function is used to re-order the `past_key_values` cache if [`~PreTrainedModel.beam_search`] or
        [`~PreTrainedModel.beam_sample`] is called. This is required to match `past_key_values` with the correct
        beam_idx at every generation step.
        c                 3   s$   | ]}t  fd d|D V  qdS )c                 3   s"   | ]}| d  |jV  qdS )r   N)Zindex_selectr   r   )r   Z
past_stater   r   r   r   }  s     z;CTRLLMHeadModel._reorder_cache.<locals>.<genexpr>.<genexpr>Nr   )r   rY   r   r   r   r   |  s   z1CTRLLMHeadModel._reorder_cache.<locals>.<genexpr>r   )r   r   r   r   r   _reorder_caches  s    	zCTRLLMHeadModel._reorder_cache)NN)NNNNNNNNNNNN)r_   r`   ra   Z_tied_weights_keysrA   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r^   staticmethodr   rb   r   r   rM   r   r     sN   

            Y r   a  
    The CTRL Model transformer with a sequence classification head on top (linear layer).
    [`CTRLForSequenceClassification`] uses the last token in order to do the classification, as other causal models
    (e.g. GPT-2) do. Since it does classification on the last token, it requires to know the position of the last
    token. If a `pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in
    each row. If no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot
    guess the padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last
    value in each row of the batch).
    c                       s   e Zd Z fddZeeeeedde	e
j e	eee
j   e	e
j e	e
j e	e
j e	e
j e	e
j e	e
j e	e e	e e	e e	e eee
j ef dddZ  ZS )	CTRLForSequenceClassificationc                    s@   t  | |j| _t|| _tj|j| jdd| _| 	  d S )NFr   )
r@   rA   
num_labelsr   rs   r   rE   r   
classifierr   r   rM   r   r   rA     s
    
z&CTRLForSequenceClassification.__init__r   Nr   c                 C   s8  |dk	r|n| j j}| j||||||||	|
||d}|d }| |}|dk	rb|jdd \}}n|jdd \}}| j jdkr|dkrtd| j jdkrd}nH|dk	rt|| j j	 
dd |j}nd}t| jj d |t||f }d}|dk	r| j jdkrf| jdkr,d	| j _n:| jdkr^|jtj	ksT|jtjkr^d
| j _nd| j _| j jd	krt }| jdkr|| | }n
|||}nN| j jd
krt }||d| j|d}n| j jdkrt }|||}|s$|f|dd  }|dk	r |f| S |S t|||j|jdS )a  
        labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
            Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
            config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
            `config.num_labels > 1` a classification loss is computed (Cross-Entropy).

        Returns:

        Example of single-label classification:

        ```python
        >>> import torch
        >>> from transformers import AutoTokenizer, CTRLForSequenceClassification

        >>> tokenizer = AutoTokenizer.from_pretrained("Salesforce/ctrl")
        >>> model = CTRLForSequenceClassification.from_pretrained("Salesforce/ctrl")

        >>> # CTRL was trained with control codes as the first token
        >>> inputs = tokenizer("Opinion My dog is cute", return_tensors="pt")
        >>> assert inputs["input_ids"][0, 0].item() in tokenizer.control_codes.values()

        >>> with torch.no_grad():
        ...     logits = model(**inputs).logits

        >>> predicted_class_id = logits.argmax().item()
        >>> model.config.id2label[predicted_class_id]
        'LABEL_0'
        ```

        ```python
        >>> import torch

        >>> torch.manual_seed(42)  # doctest: +IGNORE_RESULT
        >>> # To train a model on `num_labels` classes, you can pass `num_labels=num_labels` to `.from_pretrained(...)`
        >>> num_labels = len(model.config.id2label)
        >>> model = CTRLForSequenceClassification.from_pretrained("Salesforce/ctrl", num_labels=num_labels)

        >>> labels = torch.tensor(1)
        >>> loss = model(**inputs, labels=labels).loss
        >>> round(loss.item(), 2)
        0.35
        ```

        Example of multi-label classification:

        ```python
        >>> import torch
        >>> from transformers import AutoTokenizer, CTRLForSequenceClassification

        >>> tokenizer = AutoTokenizer.from_pretrained("Salesforce/ctrl")
        >>> model = CTRLForSequenceClassification.from_pretrained(
        ...     "Salesforce/ctrl", problem_type="multi_label_classification"
        ... )

        >>> # CTRL was trained with control codes as the first token
        >>> inputs = tokenizer("Opinion My dog is cute", return_tensors="pt")
        >>> assert inputs["input_ids"][0, 0].item() in tokenizer.control_codes.values()

        >>> with torch.no_grad():
        ...     logits = model(**inputs).logits

        >>> predicted_class_id = logits.argmax().item()
        >>> model.config.id2label[predicted_class_id]
        'LABEL_0'
        ```

        ```python
        >>> # To train a model on `num_labels` classes, you can pass `num_labels=num_labels` to `.from_pretrained(...)`
        >>> num_labels = len(model.config.id2label)
        >>> model = CTRLForSequenceClassification.from_pretrained("Salesforce/ctrl", num_labels=num_labels)

        >>> num_labels = len(model.config.id2label)
        >>> labels = torch.nn.functional.one_hot(torch.tensor([predicted_class_id]), num_classes=num_labels).to(
        ...     torch.float
        ... )
        >>> loss = model(**inputs, labels=labels).loss
        >>> loss.backward()  # doctest: +IGNORE_RESULT
        ```Nr   r   r   r   z=Cannot handle batch sizes > 1 if no padding token is defined.r"   z will not detect padding tokens in `inputs_embeds`. Results may be unexpected if using padding tokens in conjunction with `inputs_embeds.`Z
regressionZsingle_label_classificationZmulti_label_classification)r   r   r   r   )rx   r   rs   r   r0   Zpad_token_idr   r   eqr   Zargmaxr   r   loggerwarningrN   r_   r   Zproblem_typer   r!   rC   r   Zsqueezer   r   r   r   r   r   )rL   r   r   r8   r   r   r9   r   r   rZ   r[   r   r   r   r   r   rV   Zsequence_lengthZsequence_lengthsZpooled_logitsr   r   r<   r   r   r   r^     sx    `


(

z%CTRLForSequenceClassification.forward)NNNNNNNNNNNN)r_   r`   ra   rA   r   r   r   r   r   r   r   r   r   r   r   r   r   r^   rb   r   r   rM   r   r     s<   	
            r   )NN)0r}   typingr   r   r   numpyr1   r   r   Ztorch.nnr   r   r   Zmodeling_outputsr
   r   r   Zmodeling_utilsr   Zpytorch_utilsr   r   r   utilsr   r   r   r   Zconfiguration_ctrlr   Z
get_loggerr_   r   r   Z"CTRL_PRETRAINED_MODEL_ARCHIVE_LISTr   r,   r=   Moduler>   rd   re   rr   ZCTRL_START_DOCSTRINGr   r   r   r   r   r   r   r   <module>   sP   

O)= ; 	