
    g[                        d dl Z d dlZd dlZd dlZd dlmZmZmZmZ  ej                  ddej                  j                  dd      j                         ej                          ej                  d      Zd	 Zd
 Zedk(  rX e       Zej(                  dk  r edej(                   d      ej,                  j/                  ej0                        Zes ej4                  ej0                         de_        ej9                  d       ej:                  sde_        ej<                  s#ej9                  d        ej>                  e       ej@                  s#ej9                  d        ejB                  e       ejD                  s#ej9                  d        ejF                  e       ejH                  s$ej9                  d        ejJ                  e       yyy)    N)chain_enc_dec_with_beamsearchexport_summarization_edinit!export_summarization_enc_dec_pastonnx_inferencezO%(asctime)s | %(levelname)s | %(name)s |  [%(filename)s:%(lineno)d] %(message)sz%Y-%m-%d %H:%M:%SLOGLEVELINFO)formatdatefmtlevelstreamgeneratec           	      l    t        |       D ]&  }t        j                  | dt        | |              ( y )Nz: )varsloggerinfogetattr)argsargs     `/var/www/openai/venv/lib/python3.12/site-packages/onnxruntime/transformers/models/bart/export.py
print_argsr      s/    Dzse2gdC0123     c                     t        j                  d      } | j                  dt        dd       | j                  dt        dd	       | j                  d
dt        dd       | j                  ddt        d d       | j                  ddt        d d       | j                  ddt        d       | j                  ddt        dd       | j                  dt
        dd       | j                  dt        d d!       | j                  d"t        dd#       | j                  d$t        d%d&       | j                  d'd()       | j                  d*d()       | j                  d+d()       | j                  d,d()       | j                  d-      }|j                  d.d/t        d0d12       t        | j                                | j                         S )3NF)add_helpz--max_length   zdefault to 20)typedefaulthelpz--min_lengthr   zdefault to 0z-oz--outputonnx_modelszdefault name is onnx_models.z-iz--input_textz
input textz-sz
--spm_pathz!tokenizer model from sentencepicez-vz--vocab_pathzvocab dictionary)r   r   z-bz--num_beams   zdefault to 5z--repetition_penaltyg      ?zdefault to 1.0z--no_repeat_ngram_size   zdefault to 3z--early_stoppingzdefault to Falsez--opset_version   zminimum is 14z--no_encoder
store_true)actionz--no_decoderz
--no_chainz--no_inferencezrequired input argumentsz-mz--model_dirTzThe directory contains input huggingface model.                                An official model like facebook/bart-base is also acceptable.)r   requiredr   )
argparseArgumentParseradd_argumentintstrfloatbooladd_argument_groupr   
parse_args)parent_parserrequired_argss     r   user_commandr0   "   s   ++U;M~C/Z~CXtZc=Wuvt^#tR^_t\TPstt^#DVWt]an]5E3Uef7c1Sab1eRde0sB_]~lC~lC|LA/E!445OPM^   }'')*##%%r   __main__r!   z=The minimum supported opset version is 14! The given one was .cpuzENV: CPU ...a  PG&E stated it scheduled the blackouts in response to forecasts for high winds amid dry conditions. The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were scheduled to be affected by the shutoffs which were expected to last through at least midday tomorrow.z'========== EXPORTING ENCODER ==========z'========== EXPORTING DECODER ==========z'========== CONVERTING MODELS ==========z1========== INFERENCING WITH ONNX MODEL ==========)&r%   loggingossysutilsr   r   r   r   basicConfigenvirongetupperstdout	getLoggerr   r   r0   __name__r   opset_version
ValueErrorpathexistsoutputisExistmakedirsdevicer   
input_text
no_encoderexport_encoder
no_decoderexport_decoderno_chainconvert_modelno_inferencerun_inference r   r   <module>rQ      s     	 
    \
**..V
,
2
2
4::	 
		:	&4
&B z>DBXY]YkYkXllmnooggnnT[[)GDKK  DK
KK??u 	 ??=>2#2248??=>8)88>===>3%33D9GH$$$T* ; r   