o
    ho                     @   sB  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 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#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/ eeeeeeee e"e#ei ee!e$edZ0e/1e2Z3G dd dZ4dZ5dZ6i ddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1Z7g d2Z8d3d4 Z9d5d6 Z:d7d8 Z;d9d: Z<d;d< Z=d=d> Z>eG d?d@ d@Z?dAdB Z@dCdD ZAdEdF ZBdSdHdIZCdJdK ZDdLdM ZEdNdO ZFg dPZGdQdR ZHdS )Tz'Configuration base class and utilities.    N)	dataclass)Path)Any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_IMAGE_TEXT_TO_TEXT_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-classificationzimage-text-to-textc                   @   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 qI tyq } ztd| d| d|   |d }~ww d 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popr0   r1   r2   r3   r4   r5   r6   r7   r8   itemssetattrAttributeErrorloggererror)selfkwargskeyvalueerr rG   j/var/www/html/construction_image-detection-poc/venv/lib/python3.10/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_filer@   info)rB   save_directory_or_fileoutput_model_card_filerG   rG   rH   save_pretrainedr   s
   
zModelCard.save_pretrainedc              	   K   sB  | dd}| dd}| dd}| dd}ddi}|dur$||d	< tj|}tj|r5|}	d
}n6z&t|t|||d}	|rJtd|	  ntdt d|	  | 	|	}
W n t
tjfyj   |  }
Y nw g }| D ]\}}t|
|rt|
|| || qq|D ]}| |d qtd|
  |r|
|fS |
S )a	  
        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.
                - 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("google-bert/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("google-bert/bert-base-uncased", output_attentions=True, foo=False)
        ```	cache_dirNproxiesreturn_unused_kwargsF_from_pipeline	file_type
model_cardusing_pipelineT)filenamerS   rT   
user_agentzloading model card file z from cache at zModel card: )r<   rJ   rK   rL   isfiler   r   r@   rO   from_json_fileOSErrorjsonJSONDecodeErrorr=   hasattrr>   append)clspretrained_model_name_or_pathrC   rS   rT   rU   from_pipeliner[   is_localresolved_model_card_file	modelcard	to_removerD   rE   rG   rG   rH   from_pretrained}   sL   -


zModelCard.from_pretrainedc                 C   s   | di |S )z@Constructs a `ModelCard` from a Python dictionary of parameters.NrG   rG   )rc   json_objectrG   rG   rH   	from_dict   s   zModelCard.from_dictc                 C   sL   t |dd}| }W d   n1 sw   Y  t|}| di |S )z8Constructs a `ModelCard` from a json file of parameters.utf-8encodingNrG   )openreadr_   loads)rc   	json_filereadertextdict_objrG   rG   rH   r]      s
   

zModelCard.from_json_filec                 C   s   | j |j kS N)__dict__)rB   otherrG   rG   rH   __eq__      zModelCard.__eq__c                 C   s   t |  S rw   )strto_json_stringrB   rG   rG   rH   __repr__   r{   zModelCard.__repr__c                 C   s   t | j}|S )z0Serializes this instance to a Python dictionary.)copydeepcopyrx   )rB   outputrG   rG   rH   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_   dumpsr   r~   rG   rG   rH   r}      s   zModelCard.to_json_stringc                 C   sB   t |ddd}||   W d   dS 1 sw   Y  dS )z"Save this instance to a json file.wrm   rn   N)rp   writer}   )rB   json_file_pathwriterrG   rG   rH   rN      s   "zModelCard.to_json_fileN)__name__
__module____qualname____doc__rI   rR   classmethodrj   rl   r]   rz   r   r   r}   rN   rG   rG   rG   rH   r/   P   s    

]

r/   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. -->
r&   zMasked Language Modelingr$   zImage Classificationr%   zImage Segmentationzmultiple-choicezMultiple Choicer'   zObject Detectionr(   zQuestion AnsweringsummarizationSummarizationr+   zTable Question Answeringr*   zText Classificationr#   zCausal Language Modelingr)   z&Sequence-to-sequence Language Modelingr,   zToken ClassificationtranslationTranslationzzero-shot-classificationzZero Shot Classificationr.   zAutomatic Speech Recognitionr-   zAudio Classification)accuracybleuf1matthews_correlationpearsonr	precisionrecallrouge	sacrebleu	spearmanrwerc                 C   s    | d u rg S t | tr| gS | S rw   )
isinstancer|   )objrG   rG   rH   _listify+  s
   
r   c                 C   sF   |d u r| S t |tr|g}dd |D }t|dkr| S || |< | S )Nc                 S   s   g | ]}|d ur|qS rw   rG   .0vrG   rG   rH   
<listcomp>9  s    z*_insert_values_as_list.<locals>.<listcomp>r   )r   r|   len)metadatanamevaluesrG   rG   rH   _insert_values_as_list4  s   
r   c                 C   s`   | d u ri S i }|   D ]!}| ddtv r#||| dd< q| dkr-||d< q|S )N _rouge1r   )keyslowerreplaceMETRIC_TAGS)eval_resultsresultrD   rG   rG   rH   #infer_metric_tags_from_eval_results@  s   r   c                 C   s   |d u r| S || |< | S rw   rG   )r   r   rE   rG   rG   rH   _insert_valueL  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   rG   rG   rH   is_hf_datasetS  s   r   c                 C   s<   g }|   D ]}t|ttfr|t|7 }q|| q|S rw   )r   r   tuplelistrb   )mappingr   r   rG   rG   rH   _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 u r@t sB| jd urDt| jdkrFzt| j}|jD ]}|dr+|dd  | _ qW d S  tjj	tjj
tfy?   Y d S w d S d S d S d S )Nr   zlicense:   )r   r   r   r   r   r   
startswithrequests
exceptions	HTTPErrorConnectionErrorr   )rB   rO   tagrG   rG   rH   __post_init__w  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r`t dkr`|gS t|	dkrjd d i}	t dkrtd d i  fdd|	D }
|
D ]s\}}i }|d ur|	| |d|d	< |d ur|
|i } | |d||d
< || d ur|| |d
 d< t|dkrg |d< | D ]\}}|d ||| j| d qd	|v rd
|v rd|v r|d | qtd|  q|gS )Nr   c                 S   s   i | ]}|t v r|t | qS rG   )TASK_TAG_TO_NAME_MAPPING)r   taskrG   rG   rH   
<dictcomp>  s    z6TrainingSummary.create_model_index.<locals>.<dictcomp>resultsr   c                    s   g | ]} D ]}||fqqS rG   rG   )r   task_tagds_tagdataset_mappingrG   rH   r     s    z6TrainingSummary.create_model_index.<locals>.<listcomp>)r   typer   r   argsr3   )r   r   rE   zLDropping the following result as it does not have all the necessary fields:
)r   r   r   r   r   r   r   dictzipr   getr=   rb   r   r@   rO   )rB   metric_mappingmodel_indexdataset_namesr   r   r   dataset_arg_mappingdataset_metadata_mappingtask_mappingall_possibilitiesr   r   r   r   
metric_tagmetric_namerG   r   rH   create_model_index  s^   




	z"TrainingSummary.create_model_indexc                 C   s   t | j}i }t|dd}t|d| j}t|d| j}| jd ur4t| jtr4t	| jdkr4t|d| j}t|d| j
}t|d| j}t|d	t| }| ||d
< |S )Nlibrary_nametransformersr   r   r   
base_modelr   r   r3   zmodel-index)r   r   r   r   r   r   r   r   r|   r   r   r   r   r   r   )rB   r   r   rG   rG   rH   create_metadata  s   
$zTrainingSummary.create_metadatac                 C   s  d}t j|  dd}t|dkrd| d}| jdkr!|t7 }n|t7 }|d| j d7 }| jd u r8|d	7 }n|d
| j d| j d7 }| j	d u sWt
| j	tr\t| j	dkr\|d7 }nEt
| j	trl|d| j	 d7 }n5t
| j	ttfrt| j	dkr|d| j	d  d7 }n|ddd | j	d d D d| j	d  d 7 }| jd ur|d7 }|ddd | j D 7 }|d7 }|d7 }|d7 }|d7 }|d7 }|d7 }| jd ur|d7 }|dd d | j D 7 }|d7 }n|d!7 }| jd u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rBt rBdd l}|d'|j d7 }t rSdd l}|d(|j d7 }t rdd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   rG   )r   dsrG   rG   rH   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   rE   rG   rG   rH   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   rG   r   rG   rG   rH   r          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   r   r|   r   rM   r   r=   r   r   make_markdown_tabler
   r!   torchr   
tensorflowr   r   r    
tokenizers)rB   rX   r   r  tfr   r  rG   rG   rH   to_model_card  sv   



$
.


zTrainingSummary.to_model_cardc                 C   s  |j d ur|j n|j}t|r?|d u s|d u s|	d u r?|j}|dvr?|	d u r0|jt|jdg}	|d u r7|g}|d u r?|jg}|
d u rI|d urI|}
|d u rbt|jj	drbt
j|jj	jsb|jj	j}|d u r||jjj}t D ]\}}|t|v r{|}qo|d u rt|jjj}t|dkr|}|d u rdg}nt|tr|dkr|dg}n	d|vr|d t|jj\}}}t|}| |||||||
|||	|||dS )Ncsvr_   pandasparquetru   )configsplit_name_or_pathr   generated_from_trainer)r   r   r   r   r   r   r   r   r   r   r   r   r   )eval_datasettrain_datasetr   builder_nameconfig_namer|   r  ra   modelr
  rJ   rK   rL   r  	__class__r   TASK_MAPPINGr=   r   r   r   
output_dirr   r   r   rb   parse_log_historystatelog_history$extract_hyperparameters_from_trainer)rc   r   r   r   r   r   r   r   r   r   r   r   one_datasetdefault_tagmodel_class_namer   r   r   r   r   r   rG   rG   rH   from_trainer&  sf    



zTrainingSummary.from_trainerc                 C   sF  |
d ur&t |
r&|	d u s|d u r&|
j}|dvr&|	d u r|g}	|d u r&|
jg}|
d u r0|	d ur0|	}
|d u rFt|jdrFtj|jjsF|jj}|d u r_|j	j
}t D ]\}}|t|v r^|}qR|d u rgdg}nt|tru|dkru|dg}n	d|vr~|d |d urt|\}}}ng }i }t|}| |||||||	|
||||ddS )Nr  r  generated_from_keras_callbackr   )r   r   r   r   r   r   r   r   r   r   r   r   r   )r   r  r  ra   r
  rJ   rK   rL   r  r  r   r  r=   r   r   r|   rb   parse_keras_history"extract_hyperparameters_from_keras)rc   r  r   keras_historyr   r   r   r   r   r   r   r   r  r  r   r   r   r   r   r   rG   rG   rH   
from_kerast  s`   


zTrainingSummary.from_keras)
NNNNNNNNNN)	NNNNNNNNN)r   r   r   r|   __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"  rG   rG   rG   rH   r   f  sT   
 ?PMr   c           	         s   t drt dsdg i fS jjd< jnfddd D g }ttd D ]F  fdd D }i }| D ]-\}}|drSd	|d
d  }n|dkr[d| }|d}ddd |D }|||< qA|	| q.|d }||fS )z
    Parse the `logs` of either a `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 rG   rG   )r   single_dictlog_keyrG   rH   r         z2parse_keras_history.<locals>.<dictcomp>.<listcomp>rG   )r   )logsr(  rH   r     r   z'parse_keras_history.<locals>.<dictcomp>r   c                    s   i | ]	\}}||  qS rG   rG   )r   r)  log_value_list)irG   rH   r         val_validation_   train_r   r   c                 S      g | ]}|  qS rG   
capitalizer   partrG   rG   rH   r     r*  z'parse_keras_history.<locals>.<listcomp>r   )
ra   r&  r%  ranger   r=   r   r  rM   rb   )	r+  lines
epoch_dictr   kr   splitsr   r   rG   )r-  r+  rH   r    s*   






r  c                 C   s\  d}|t | k rd| | vr|d7 }|t | k rd| | vs|t | krM|d8 }|dkr@d| | vr@|d8 }|dkr@d| | vs2|dkrKdd| | fS dS | | }g }d}t|D ]x}d| | v rg| | d }d| | v r| |  }|d	d}|d
d}|dd}	|dd}|dd}|dd}|dd}|||	d}
| D ]$\}}|dkr||
d< q|d}ddd |dd D }||
|< q||
 qYt | d }|dkrd| | vr|d8 }|dkrd| | vs|dkr)i }| |  D ]&\}}|dr|dd }|dvr#ddd |dD }|||< q|||fS ||dfS )zd
    Parse the `log_history` of a Trainer to get the intermediate and final evaluation results.
    r   train_runtimer	   	eval_lossN)NNNzNo logloss
total_flosr&  stepeval_runtimeeval_samples_per_secondeval_steps_per_secondeval_jit_compilation_time)zTraining LossEpochStepzValidation Lossr   r   c                 S   r3  rG   r4  r6  rG   rG   rH   r     r*  z%parse_log_history.<locals>.<listcomp>eval_   )runtimesamples_per_secondsteps_per_secondr&  rA  c                 S   r3  rG   r4  r6  rG   rG   rH   r     r*  )	r   r8  r   r<   r=   r  rM   rb   r   )r  idx	train_logr9  training_lossr-  r3   r   r&  rA  r   r;  r   r<  r   r   rD   rE   camel_cased_keyrG   rG   rH   r    sf   







r  c                 C   sP   ddl m} i }t| dr| jd ur| j |d< nd |d< |j j|d< |S )Nr	   )r   	optimizertraining_precision)modeling_tf_utilsr   ra   rQ  
get_configmixed_precisionglobal_policyr   )r  r   r   rG   rG   rH   r   !  s   r   r1  c                 C   sR   t | tr%tt| ddkr%tt| dd |kr%| d| dS t| S )N.r	   f)r   r$  r   r|   r  )r   decimalsrG   rG   rH   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   rG   rG   rH   r   5  s   . z'_regular_table_line.<locals>.<listcomp>r   |
)r   rM   )r   
col_widthsvalues_with_spacerG   rG   rH   _regular_table_line4  s   r]  c                 C   s   dd | D }d |d S )Nc                 S   s   g | ]
}d d|  d qS )z|:-:rG   )r   r   rG   rG   rH   r   :  s    z&_second_table_line.<locals>.<listcomp>r   rZ  )rM   )r[  r   rG   rG   rH   _second_table_line9  s   r`  c                 C   s   | du s
t | dkrdS dd | d  D }| D ]}| D ]\}}|| t t|k r5t t|||< qqtt| d  t| }|tt| 7 }| D ]}|tdd | D t| 7 }qR|S )zC
    Create a nice Markdown table from the results in `lines`.
    Nr   r   c                 S   s   i | ]	}|t t|qS rG   )r   r|   )r   rD   rG   rG   rH   r   D  r.  z'make_markdown_table.<locals>.<dictcomp>c                 S   s   g | ]}t |qS rG   r   r   rG   rG   rH   r   M  r*  z'make_markdown_table.<locals>.<listcomp>)r   r   r=   r   r]  r   r   r`  )r9  r[  linerD   rE   tablerG   rG   rH   r   >  s   &r   )learning_ratetrain_batch_sizeeval_batch_sizeseedc              
      s   fddt D } jjtjtjfvr# jjtjkrdn jjj|d<  jjdkr/ jj|d<  jj	dkr; jj	|d<  jj
 jj  jj	 }||d krQ||d	<  jj jj }||d
 krc||d<  jjr jj} jjrs jjnd}d| v rd| d jj d jj d jj d| 
|d< n
d| d| |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 jj |d< nd|d<  jjdkr jj|d< |S ) Nc                    s   i | ]	}|t  j|qS rG   )getattrr   )r   r;  r   rG   rH   r   Z  r.  z8extract_hyperparameters_from_trainer.<locals>.<dictcomp>z	multi-GPUdistributed_typer	   num_devicesgradient_accumulation_stepsrd  total_train_batch_sizere  total_eval_batch_sizez!No additional optimizer argumentsadamzUse z with betas=(,z) and epsilon=z and optimizer_args=rQ  z and the args are:
lr_scheduler_typeg        lr_scheduler_warmup_ratiolr_scheduler_warmup_stepsr   training_steps
num_epochszApex, opt level mixed_precision_trainingz
Native AMPlabel_smoothing_factor)_TRAINING_ARGS_KEYSr   parallel_moder   NOT_PARALLELNOT_DISTRIBUTEDDISTRIBUTEDrE   
world_sizerk  rd  re  optim
optim_argsr   
adam_beta1
adam_beta2adam_epsilonrp  warmup_ratiowarmup_steps	max_stepsnum_train_epochsfp16use_apexfp16_opt_levelrv  )r   r   rl  rm  optimizer_nameoptimizer_argsrG   rh  rH   r  Y  sR   r  )r1  )Ir   r   r_   rJ   r9   dataclassesr   pathlibr   typingr   r   r   r   r   huggingface_hubr   huggingface_hub.utilsr   r   r
   models.auto.modeling_autor   r   r   r   r   r   r   r   r   r   r   r   r   r   r   training_argsr   utilsr   r   r   r   r   r    r!   r"   r  
get_loggerr   r@   r/   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r   r]  r`  r   rw  r  rG   rG   rG   rH   <module>   s   D(

 .	
		
  [#>
