U
    9%e                     @   s  d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZmZmZ ddlZddlZddl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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/m0Z0 eeeeeee e!e#e$eee"e%dZ1e02e3Z4G dd dZ5dZ6dZ7ddddddddddddddd d!d"Z8d#d$d%d&d'd(d)d*d+d,d-gZ9d.d/ Z:d0d1 Z;d2d3 Z<d4d5 Z=d6d7 Z>d8d9 Z?eG d:d; d;Z@d<d= ZAd>d? ZBd@dA ZCdQdCdDZDdEdF ZEdGdH ZFdIdJ ZGdKdLdMdNgZHdOdP ZIdS )Rz( Configuration base class and utilities.    N)	dataclass)Path)AnyDictListOptionalUnion)
model_info)HFValidationError   )__version__),MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING_NAMES!MODEL_FOR_CAUSAL_LM_MAPPING_NAMESMODEL_FOR_CTC_MAPPING_NAMES,MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING_NAMES*MODEL_FOR_IMAGE_SEGMENTATION_MAPPING_NAMES!MODEL_FOR_MASKED_LM_MAPPING_NAMES(MODEL_FOR_OBJECT_DETECTION_MAPPING_NAMES*MODEL_FOR_QUESTION_ANSWERING_MAPPING_NAMES,MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING_NAMES/MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING_NAMES(MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING_NAMES0MODEL_FOR_TABLE_QUESTION_ANSWERING_MAPPING_NAMES,MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING_NAMES6MODEL_FOR_ZERO_SHOT_IMAGE_CLASSIFICATION_MAPPING_NAMES)ParallelMode)MODEL_CARD_NAMEcached_fileis_datasets_availableis_offline_modeis_tf_availableis_tokenizers_availableis_torch_availablelogging)text-generationimage-classificationimage-segmentation	fill-maskobject-detectionquestion-answeringtext2text-generationtext-classificationtable-question-answeringtoken-classificationaudio-classificationautomatic-speech-recognitionzzero-shot-image-classificationc                   @   sl   e Zd ZdZdd Zdd Zedd Zedd	 Zed
d Z	dd Z
dd Zdd Zdd Zdd ZdS )	ModelCarda  
    Structured Model Card class. Store model card as well as methods for loading/downloading/saving model cards.

    Please read the following paper for details and explanation on the sections: "Model Cards for Model Reporting" by
    Margaret Mitchell, Simone Wu, Andrew Zaldivar, Parker Barnes, Lucy Vasserman, Ben Hutchinson, Elena Spitzer,
    Inioluwa Deborah Raji and Timnit Gebru for the proposal behind model cards. Link: https://arxiv.org/abs/1810.03993

    Note: A model card can be loaded and saved to disk.
    c                 K   s   t dt |di | _|di | _|di | _|di | _|di | _|di | _	|di | _
|d	i | _|d
i | _| D ]\\}}zt| || W q tk
r } z$td| d| d|   |W 5 d }~X Y qX qd S )NzTThe class `ModelCard` is deprecated and will be removed in version 5 of Transformersmodel_detailsintended_usefactorsmetricsevaluation_datatraining_dataquantitative_analysesethical_considerationscaveats_and_recommendationsz
Can't set z with value z for )warningswarnFutureWarningpopr1   r2   r3   r4   r5   r6   r7   r8   r9   itemssetattrAttributeErrorloggererror)selfkwargskeyvalueerr rH   U/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/transformers/modelcard.py__init__[   s&     zModelCard.__init__c                 C   s>   t j|rt j|t}n|}| | td|  dS )zKSave a model card object to the directory or file `save_directory_or_file`.zModel card saved in N)ospathisdirjoinr   to_json_filerA   info)rC   Zsave_directory_or_fileZoutput_model_card_filerH   rH   rI   save_pretrainedr   s
    
zModelCard.save_pretrainedc              	   K   sL  | dd}| dd}| dd}| dd}ddi}|dk	rH||d	< tj|}tj|rj|}	d
}nnzLt|t|||d}	|rtd|	  ntdt d|	  | 	|	}
W n  t
tjfk
r   |  }
Y nX g }| D ](\}}t|
|rt|
|| || q|D ]}| |d qtd|
  |rD|
|fS |
S dS )aF
  
        Instantiate a [`ModelCard`] from a pre-trained model model card.

        Parameters:
            pretrained_model_name_or_path: either:

                - a string, the *model id* of a pretrained model card hosted inside a model repo on huggingface.co.
                  Valid model ids can be located at the root-level, like `bert-base-uncased`, or namespaced under a
                  user or organization name, like `dbmdz/bert-base-german-cased`.
                - a path to a *directory* containing a model card file saved using the [`~ModelCard.save_pretrained`]
                  method, e.g.: `./my_model_directory/`.
                - a path or url to a saved model card JSON *file*, e.g.: `./my_model_directory/modelcard.json`.

            cache_dir: (*optional*) string:
                Path to a directory in which a downloaded pre-trained model card should be cached if the standard cache
                should not be used.

            kwargs: (*optional*) dict: key/value pairs with which to update the ModelCard object after loading.

                - The values in kwargs of any keys which are model card attributes will be used to override the loaded
                  values.
                - Behavior concerning key/value pairs whose keys are *not* model card attributes is controlled by the
                  *return_unused_kwargs* keyword parameter.

            proxies: (*optional*) dict, default None:
                A dictionary of proxy servers to use by protocol or endpoint, e.g.: {'http': 'foo.bar:3128',
                'http://hostname': 'foo.bar:4012'}. The proxies are used on each request.

            return_unused_kwargs: (*optional*) bool:

                - If False, then this function returns just the final model card object.
                - If True, then this functions returns a tuple *(model card, unused_kwargs)* where *unused_kwargs* is a
                  dictionary consisting of the key/value pairs whose keys are not model card attributes: ie the part of
                  kwargs which has not been used to update *ModelCard* and is otherwise ignored.

        Examples:

        ```python
        # Download model card from huggingface.co and cache.
        modelcard = ModelCard.from_pretrained("bert-base-uncased")
        # Model card was saved using *save_pretrained('./test/saved_model/')*
        modelcard = ModelCard.from_pretrained("./test/saved_model/")
        modelcard = ModelCard.from_pretrained("./test/saved_model/modelcard.json")
        modelcard = ModelCard.from_pretrained("bert-base-uncased", output_attentions=True, foo=False)
        ```	cache_dirNproxiesreturn_unused_kwargsFZ_from_pipeline	file_type
model_cardZusing_pipelineT)filenamerR   rS   
user_agentzloading model card file z from cache at zModel card: )r=   rK   rL   rM   isfiler   r   rA   rP   from_json_fileEnvironmentErrorjsonJSONDecodeErrorr>   hasattrr?   append)clsZpretrained_model_name_or_pathrD   rR   rS   rT   Zfrom_pipelinerX   is_localZresolved_model_card_fileZ	modelcardZ	to_removerE   rF   rH   rH   rI   from_pretrained}   sH    /
zModelCard.from_pretrainedc                 C   s
   | f |S )z@Constructs a `ModelCard` from a Python dictionary of parameters.rH   )r`   Zjson_objectrH   rH   rI   	from_dict   s    zModelCard.from_dictc              	   C   s6   t |ddd}| }W 5 Q R X t|}| f |S )z8Constructs a `ModelCard` from a json file of parameters.rutf-8encoding)openreadr\   loads)r`   Z	json_filereadertextdict_objrH   rH   rI   rZ      s    
zModelCard.from_json_filec                 C   s   | j |j kS N)__dict__)rC   otherrH   rH   rI   __eq__   s    zModelCard.__eq__c                 C   s   t |  S rn   )strto_json_stringrC   rH   rH   rI   __repr__   s    zModelCard.__repr__c                 C   s   t | j}|S )z0Serializes this instance to a Python dictionary.)copydeepcopyro   )rC   outputrH   rH   rI   to_dict   s    zModelCard.to_dictc                 C   s   t j|  dddd S )z*Serializes this instance to a JSON string.   T)indent	sort_keys
)r\   dumpsry   rt   rH   rH   rI   rs      s    zModelCard.to_json_stringc              	   C   s,   t |ddd}||   W 5 Q R X dS )z"Save this instance to a json file.wre   rf   N)rh   writers   )rC   Zjson_file_pathwriterrH   rH   rI   rO      s    zModelCard.to_json_fileN)__name__
__module____qualname____doc__rJ   rQ   classmethodrb   rc   rZ   rq   ru   ry   rs   rO   rH   rH   rH   rI   r0   P   s   

_

r0   z
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->
z
<!-- This model card has been generated automatically according to the information Keras had access to. You should
probably proofread and complete it, then remove this comment. -->
zMasked Language ModelingzImage ClassificationzImage SegmentationzMultiple ChoicezObject DetectionzQuestion AnsweringZSummarizationzTable Question AnsweringzText ClassificationzCausal Language Modelingz&Sequence-to-sequence Language ModelingzToken ClassificationZTranslationzZero Shot ClassificationzAutomatic Speech RecognitionzAudio Classification)r'   r%   r&   zmultiple-choicer(   r)   Zsummarizationr,   r+   r$   r*   r-   translationzzero-shot-classificationr/   r.   ZaccuracyZbleuf1Zmatthews_correlationZpearsonr	precisionZrecallrougeZ	sacrebleuZ	spearmanrZwerc                 C   s$   | d krg S t | tr| gS | S d S rn   )
isinstancerr   )objrH   rH   rI   _listify-  s
    
r   c                 C   sF   |d kr| S t |tr|g}dd |D }t|dkr:| S || |< | S )Nc                 S   s   g | ]}|d k	r|qS rn   rH   .0vrH   rH   rI   
<listcomp>;  s      z*_insert_values_as_list.<locals>.<listcomp>r   )r   rr   len)metadatanamevaluesrH   rH   rI   _insert_values_as_list6  s    
r   c                 C   s`   | d kri S i }|   D ]B}| ddtkrF||| dd< q| dkr||d< q|S )N _Zrouge1r   )keyslowerreplaceMETRIC_TAGS)eval_resultsresultrE   rH   rH   rI   #infer_metric_tags_from_eval_resultsB  s    
r   c                 C   s   |d kr| S || |< | S rn   rH   )r   r   rF   rH   rH   rI   _insert_valueN  s    r   c                 C   s(   t  s
dS ddlm}m} t| ||fS )NFr   )DatasetIterableDataset)r   datasetsr   r   r   )datasetr   r   rH   rH   rI   is_hf_datasetU  s    r   c                 C   s<   g }|   D ]*}t|ttfr,|t|7 }q|| q|S rn   )r   r   tuplelistr_   )mappingr   r   rH   rH   rI   _get_mapping_values^  s    r   c                   @   s  e Zd ZU eed< dZeeeee f  ed< dZ	ee ed< dZ
eeeee f  ed< dZee ed< dZeeeee f  ed< dZeeeee f  ed< dZeeeee f  ed	< dZeeeee f  ed
< dZeeeef  ed< dZeeeef  ed< dZeee  ed< dZeeeef  ed< dZee ed< dd Zdd Zdd Zdd ZedddZedddZdS )TrainingSummary
model_nameNlanguagelicensetagsfinetuned_fromtasksr   dataset_tagsdataset_argsdataset_metadatar   
eval_lineshyperparameterstrainersourcec              
   C   s   | j d kr~t s~| jd k	r~t| jdkr~z2t| j}|jD ]}|dr:|dd  | _ q:W n" tjj	tjj
tfk
r|   Y nX d S )Nr   zlicense:   )r   r   r   r   r	   r   
startswithrequests
exceptions	HTTPErrorConnectionErrorr
   )rC   rP   tagrH   rH   rI   __post_init__y  s    


zTrainingSummary.__post_init__c                    s  d| j i}t| j}t| j}t| j}t| j}t|t|k r\|d gt|t|   }tt|| tt||}tt||}dd t| j	D }	g |d< t|	dkrt dkr|gS t|	dkrd d i}	t dkrd d i  fdd|	D }
|
D ]\}}i }|d k	r&|	| |d|d	< |d k	rp|
|i } | |d||d
< || d k	rp|| |d
 d< t|dkrg |d< | D ]&\}}|d ||| j| d qd	|krd
|krd|kr|d | qtd|  q|gS )Nr   c                 S   s   i | ]}|t kr|t | qS rH   )TASK_TAG_TO_NAME_MAPPING)r   taskrH   rH   rI   
<dictcomp>  s      z6TrainingSummary.create_model_index.<locals>.<dictcomp>resultsr   c                    s   g | ]} D ]}||fqqS rH   rH   )r   task_tagds_tagZdataset_mappingrH   rI   r     s       z6TrainingSummary.create_model_index.<locals>.<listcomp>)r   typer   r   argsr4   )r   r   rF   zLDropping the following result as it does not have all the necessary fields:
)r   r   r   r   r   r   r   dictzipr   getr>   r_   r   rA   rP   )rC   metric_mappingZmodel_indexZdataset_namesr   r   r   Zdataset_arg_mappingZdataset_metadata_mappingZtask_mappingZall_possibilitiesr   r   r   r   Z
metric_tagZmetric_namerH   r   rI   create_model_index  s^    






	z"TrainingSummary.create_model_indexc                 C   s   t | j}i }t|d| j}t|d| j}| jd k	r\t| jtr\t	| jdkr\t|d| j}t|d| j
}t|d| j}t|dt| }| ||d< |S )	Nr   r   r   Z
base_modelr   r   r4   zmodel-index)r   r   r   r   r   r   r   r   rr   r   r   r   r   r   r   )rC   r   r   rH   rH   rI   create_metadata  s    
$zTrainingSummary.create_metadatac                 C   s  d}t j|  dd}t|dkr.d| d}| jdkrB|t7 }n|t7 }|d| j d7 }| jd krp|d	7 }n|d
| j d| j d7 }| j	d kr|d7 }nt
| j	tr|d| j	 d7 }njt
| j	ttfrt| j	dkr|d| j	d  d7 }n4|ddd | j	d d D d| j	d  d 7 }| jd k	rZ|d7 }|ddd | j D 7 }|d7 }|d7 }|d7 }|d7 }|d7 }|d7 }| jd k	r|d7 }|dd d | j D 7 }|d7 }n|d!7 }| jd k	r|d"7 }|t| j7 }|d7 }|d#7 }|d$t d7 }| jdkr@t r@dd l}|d%|j d7 }n.| jd&krnt rndd l}|d'|j d7 }t rdd l}|d(|j d7 }t rdd l}|d)|j d7 }|S )*N F)r|   r   z---
r   z
# z

z'This model was trained from scratch on z'This model is a fine-tuned version of [z](https://huggingface.co/z) on zan unknown dataset.the z	 dataset.r   z, c                 S   s   g | ]}d | qS )r   rH   )r   ZdsrH   rH   rI   r     s     z1TrainingSummary.to_model_card.<locals>.<listcomp>z	 and the z
 datasets.z:
It achieves the following results on the evaluation set:
r}   c                 S   s$   g | ]\}}d | dt | qS z- z: _maybe_roundr   r   rF   rH   rH   rI   r     s     z/
## Model description

More information needed
z9
## Intended uses & limitations

More information needed
z:
## Training and evaluation data

More information needed
z
## Training procedure
z
### Training hyperparameters
z:
The following hyperparameters were used during training:
c                 S   s    g | ]\}}d | d| qS r   rH   r   rH   rH   rI   r     s     z
More information needed
z
### Training results

z
### Framework versions

z- Transformers z
- Pytorch kerasz- TensorFlow z- Datasets z- Tokenizers )yamldumpr   r   r   AUTOGENERATED_TRAINER_COMMENTAUTOGENERATED_KERAS_COMMENTr   r   r   r   rr   r   r   rN   r   r>   r   r   make_markdown_tabler   r"   torchr    
tensorflowr   r   r!   
tokenizers)rC   rV   r   r   tfr   r   rH   rH   rI   to_model_card  sn    





.
zTrainingSummary.to_model_cardc                 C   s  |j d k	r|j n|j}t|r~|d ks6|d ks6|	d kr~|j}|dkr~|	d kr`|jt|jdg}	|d krn|g}|d kr~|jg}|
d kr|d k	r|}
|d krt|jj	drt
j|jj	js|jj	j}|d kr|jjj}t D ]\}}|t|kr|}q|d krt|jjj}t|dkr"|}|d kr4dg}n4t|trT|dkrT|dg}nd|krh|d t|jj\}}}t|}| |||||||
|||	|||dS )Ncsvr\   ZpandasZparquetrl   )configsplit_name_or_pathr   Zgenerated_from_trainer)r   r   r   r   r   r   r   r   r   r   r   r   r   )Zeval_datasetZtrain_datasetr   builder_nameconfig_namerr   r   r^   modelr   rK   rL   rM   r   	__class__r   TASK_MAPPINGr>   r   r   r   
output_dirr   r   r   r_   parse_log_historystatelog_history$extract_hyperparameters_from_trainer)r`   r   r   r   r   r   r   r   r   r   r   r   Zone_datasetdefault_tagmodel_class_namer   r   r   r   r   r   rH   rH   rI   from_trainer'  sf     






zTrainingSummary.from_trainerc                 C   sH  |
d k	rLt |
rL|	d ks |d krL|
j}|dkrL|	d kr<|g}	|d krL|
jg}|
d kr`|	d k	r`|	}
|d krt|jdrtj|jjs|jj}|d kr|j	j
}t D ]\}}|t|kr|}q|d krdg}n.t|tr|dkr|dg}nd|kr|d |d k	rt|\}}}ng }i }t|}| |||||||	|
||||ddS )Nr   r   Zgenerated_from_keras_callbackr   )r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r^   r   rK   rL   rM   r   r   r   r   r>   r   r   rr   r_   parse_keras_history"extract_hyperparameters_from_keras)r`   r   r   Zkeras_historyr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rH   rH   rI   
from_kerasu  s`    



zTrainingSummary.from_keras)
NNNNNNNNNN)	NNNNNNNNN)r   r   r   rr   __annotations__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   floatr   r   r   r   r   r   r   r   r   r   rH   rH   rH   rI   r   h  sR   
?P          M         r   c           	         s   t dr2t dsdg i fS jjd< jnfddd D g }ttd D ]  fdd D }i }| D ]Z\}}|drd	|d
d  }n|dkrd| }|d}ddd |D }|||< q|	| q\|d }||fS )z
    Parse the `logs` of either a `tf.keras.History` object returned by `model.fit()` or an accumulated logs `dict`
    passed to the `PushToHubCallback`. Returns lines and logs compatible with those returned by `parse_log_history`.
    historyepochNc                    s    i | ]   fd dD qS )c                    s   g | ]}|  qS rH   rH   )r   Zsingle_dictlog_keyrH   rI   r     s     z2parse_keras_history.<locals>.<dictcomp>.<listcomp>rH   )r   )logsr   rI   r     s      z'parse_keras_history.<locals>.<dictcomp>r   c                    s   i | ]\}}||  qS rH   rH   )r   r   Zlog_value_list)irH   rI   r     s      Zval_Zvalidation_   Ztrain_r   r   c                 S   s   g | ]}|  qS rH   
capitalizer   partrH   rH   rI   r     s     z'parse_keras_history.<locals>.<listcomp>r   )
r^   r   r   ranger   r>   r   r   rN   r_   )	r   linesZ
epoch_dictr   kr   splitsr   r   rH   )r   r   rI   r     s*    





r   c                 C   s2  d}|t | k r&d| | kr&|d7 }q|t | krr|d8 }|dkrXd| | krX|d8 }q:|dkrndd| | fS dS | | }g }d}t|D ]}d| | kr| | d }d| | kr| |  }|d	d}|d
d}|dd}	|dd}|dd}|dd}|dd}|||	d}
| D ]L\}}|dkrB||
d< n.|d}ddd |dd D }||
|< q&||
 qt | d }|dkrd| | kr|d8 }q|dkr$i }| |  D ]N\}}|dr|dd }|dkrddd |dD }|||< q|||fS ||dfS dS )zd
    Parse the `log_history` of a Trainer to get the intermediate and final evaluation results.
    r   Ztrain_runtimer   Z	eval_lossN)NNNzNo logZlossZ
total_flosr   stepZeval_runtimeZeval_samples_per_secondZeval_steps_per_secondZeval_jit_compilation_time)zTraining LossZEpochZStepzValidation Lossr   r   c                 S   s   g | ]}|  qS rH   r   r  rH   rH   rI   r     s     z%parse_log_history.<locals>.<listcomp>Zeval_   )ZruntimeZsamples_per_secondZsteps_per_secondr   r  c                 S   s   g | ]}|  qS rH   r   r  rH   rH   rI   r     s     )	r   r  rv   r=   r>   r   rN   r_   r   )r   idxZ	train_logr  Ztraining_lossr   r4   r   r   r  r   r  r   r  r   r   rE   rF   Zcamel_cased_keyrH   rH   rI   r     s\    







r   c                 C   sN   dd l }i }t| dr0| jd k	r0| j |d< nd |d< |jj j|d< |S )Nr   	optimizerZtraining_precision)r   r^   r
  Z
get_configr   Zmixed_precisionZglobal_policyr   )r   r   r   rH   rH   rI   r   "  s    r   r   c                 C   sR   t | trJtt| ddkrJtt| dd |krJ| d| dS t| S )N.r   f)r   r   r   rr   r   )r   ZdecimalsrH   rH   rI   r   /  s    :r   c                 C   s"   dd t | |D }d|d S )Nc                 S   s.   g | ]&\}}d | d|t | d   qS )z| r   r   )r   )r   r   r   rH   rH   rI   r   6  s     z'_regular_table_line.<locals>.<listcomp>r   |
)r   rN   )r   
col_widthsZvalues_with_spacerH   rH   rI   _regular_table_line5  s    r  c                 C   s   dd | D }d |d S )Nc                 S   s   g | ]}d d|  d qS )z|:-:rH   )r   r   rH   rH   rI   r   ;  s     z&_second_table_line.<locals>.<listcomp>r   r  )rN   )r  r   rH   rH   rI   _second_table_line:  s    r  c                 C   s   | dkst | dkrdS dd | d  D }| D ]:}| D ],\}}|| t t|k r>t t|||< q>q2tt| d  t| }|tt| 7 }| D ](}|tdd | D t| 7 }q|S )zC
    Create a nice Markdown table from the results in `lines`.
    Nr   r   c                 S   s   i | ]}|t t|qS rH   )r   rr   )r   rE   rH   rH   rI   r   E  s      z'make_markdown_table.<locals>.<dictcomp>c                 S   s   g | ]}t |qS rH   r   r   rH   rH   rI   r   N  s     z'make_markdown_table.<locals>.<listcomp>)r   r   r>   r   r  r   r   r  )r  r  linerE   rF   tablerH   rH   rI   r   ?  s    &r   Zlearning_ratetrain_batch_sizeeval_batch_sizeseedc                    s   fddt D } jjtjtjfkrF jjtjkr8dn jjj|d<  jjdkr^ jj|d<  jj	dkrv jj	|d<  jj
 jj  jj	 }||d kr||d	<  jj jj }||d
 kr||d<  jjrd|d< n&d jj d jj d jj |d<  jjj|d<  jjdkr& jj|d<  jjdkr@ jj|d<  jjdkr\ jj|d< n jj|d<  jjr jrd|d< n jrd jj |d<  jjdkr jj|d< |S )Nc                    s   i | ]}|t  j|qS rH   )getattrr   )r   r  r   rH   rI   r   [  s      z8extract_hyperparameters_from_trainer.<locals>.<dictcomp>z	multi-GPUZdistributed_typer   Znum_devicesgradient_accumulation_stepsr  total_train_batch_sizer  total_eval_batch_sizeZ	Adafactorr
  zAdam with betas=(,z) and epsilon=lr_scheduler_typeg        Zlr_scheduler_warmup_ratioZlr_scheduler_warmup_stepsr   Ztraining_stepsZ
num_epochsz
Native AMPZmixed_precision_trainingzApex, opt level label_smoothing_factor)_TRAINING_ARGS_KEYSr   Zparallel_moder   ZNOT_PARALLELZNOT_DISTRIBUTEDZDISTRIBUTEDrF   Z
world_sizer  r  r  Z	adafactorZ
adam_beta1Z
adam_beta2Zadam_epsilonr  Zwarmup_ratioZwarmup_stepsZ	max_stepsZnum_train_epochsZfp16Zuse_cuda_ampZuse_apexZfp16_opt_levelr  )r   r   r  r  rH   r  rI   r   Z  sF    
 

r   )r   )Jr   rv   r\   rK   r:   dataclassesr   pathlibr   typingr   r   r   r   r   r   r   Zhuggingface_hubr	   Zhuggingface_hub.utilsr
   r   r   Zmodels.auto.modeling_autor   r   r   r   r   r   r   r   r   r   r   r   r   r   Ztraining_argsr   utilsr   r   r   r   r    r!   r"   r#   r   Z
get_loggerr   rA   r0   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r   r   rH   rH   rH   rI   <module>   s   @(
 0		
  Z#>
