L i/UdZddlZddlZddlZddlZddlZddlmZmZmZm Z m Z m Z m Z m Z ddlmZddlmZddlmZddlmZej0Zdaeej6ed<ejejejejejej dZejZej> a d Z!d e"fd Z#d ejHfd Z%d-d Z&d-dZ'dZ(dZd.dee"d ejHfdZ)d e*fdZ+de*d dfdZ,dZ-dZ.dZ/dZ0d-dZ1d-dZ2dej6d dfdZ3dej6d dfdZ4d-dZ5d-d Z6d-d!Z7d-d"Z8d#Z9e9ejH_9ejtdd$Z;e;ejH_;ejtdd%Ze>Zd e?fd*Z@d+ZAd,ZBy)/zLogging utilities.N)CRITICALDEBUGERRORFATALINFONOTSETWARNWARNING)captureWarnings)Optional)auto_default_handler)detaildebuginfowarningerrorcriticalc tjdd}|r[|tvr t|Stjj d|ddj tjtS)z If TRANSFORMERS_VERBOSITY env var is set to one of the valid choices return that as the new default level. If it is not - fall back to `_default_log_level` TRANSFORMERS_VERBOSITYNz&Unknown option TRANSFORMERS_VERBOSITY=z, has to be one of: z, ) osgetenv log_levelslogging getLoggerrjoinkeys_default_log_level) env_level_strs `/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/transformers/utils/logging.py_get_default_logging_levelr!7ss II6=M J &m, ,     ' '8H%%)YYz/@%A$BD  returnc2tjddS)N.r)__name__splitr"r _get_library_namer)Hs >># q !!r"c<tjtSN)rrr)r(r"r _get_library_root_loggerr,Ls   .0 11r"ct5tr dddytjatj #t tjdt_tj jt_ t}|jt|jttjdddk(r*tjd}tj!|tjdduxr%tjdj#dv}||_dddy#1swYyxYw)NwrrzB[%(levelname)s|%(pathname)s:%(lineno)s] %(asctime)s >> %(message)sCI>1ONYESTRUE)_lockrr StreamHandlersysstderropenrdevnullflushr, addHandlersetLevelr!r Formatter setFormatterupper propagate)library_root_logger formatteris_cis r _configure_library_root_loggerrDPs .  ..#002 :: bjj#.CJ!$!1!178&&'78$$%?%AB 99-t 4 @))*noI  ) )) 4 $t+e $0E0E0GKe0e(-%+...sE D*E  Ect5ts dddyt}|jt|j t j dadddy#1swYyxYwr+)r4rr, removeHandlerr<rr)rAs r _reset_library_root_loggerrGks^     78))*:;$$W^^4   sA!AA!!A*ctSr+)rr(r"r get_log_levels_dictrIxs r"ctd}|js|jt|j t j t|y)a Calls the `captureWarnings` method from the logging library to enable management of the warnings emitted by the `warnings` library. Read more about this method here: https://docs.python.org/3/library/logging.html#integration-with-the-warnings-module All warnings will be logged through the `py.warnings` logger. Careful: this method also adds a handler to this logger if it does not already have one, and updates the logging level of that logger to the library's root logger. z py.warningsN) get_loggerhandlersr;rr<r,level_captureWarnings)captureloggers r r r |sB &F ??*+ OO,.445Wr"namecX| t}ttj|S)z Return a logger with the specified name. This function is not supposed to be directly accessed unless you are writing a custom transformers module. )r)rDrr)rQs r rKrKs( | ""$   T ""r"cFttjS)u Return the current level for the 🤗 Transformers's root logger as an int. Returns: `int`: The logging level. 🤗 Transformers has following logging levels: - 50: `transformers.logging.CRITICAL` or `transformers.logging.FATAL` - 40: `transformers.logging.ERROR` - 30: `transformers.logging.WARNING` or `transformers.logging.WARN` - 20: `transformers.logging.INFO` - 10: `transformers.logging.DEBUG` )rDr,getEffectiveLevelr(r"r get_verbosityrUs&#$ # % 7 7 99r" verbositycJttj|y)u Set the verbosity level for the 🤗 Transformers's root logger. Args: verbosity (`int`): Logging level, e.g., one of: - `transformers.logging.CRITICAL` or `transformers.logging.FATAL` - `transformers.logging.ERROR` - `transformers.logging.WARNING` or `transformers.logging.WARN` - `transformers.logging.INFO` - `transformers.logging.DEBUG` N)rDr,r<)rVs r set_verbosityrXs#$'' 2r"c ttS)z&Set the verbosity to the `INFO` level.)rXrr(r"r set_verbosity_inforZs  r"c ttS)z)Set the verbosity to the `WARNING` level.)rXr r(r"r set_verbosity_warningr\s  !!r"c ttS)z'Set the verbosity to the `DEBUG` level.)rXrr(r"r set_verbosity_debugr^  r"c ttS)z'Set the verbosity to the `ERROR` level.)rXrr(r"r set_verbosity_errorrar_r"cbttJtjty)zJDisable the default handler of the HuggingFace Transformers's root logger.N)rDrr,rFr(r"r disable_default_handlerrcs(#$  '' ',,-=>r"cbttJtjty)zIEnable the default handler of the HuggingFace Transformers's root logger.N)rDrr,r;r(r"r enable_default_handlerres(#$  '' '))*:;r"handlercRt|Jtj|y)z=adds a handler to the HuggingFace Transformers's root logger.N)rDr,r;rfs r add_handlerris'#$   ))'2r"c~t||tjvsJtj|y)zFremoves given handler from the HuggingFace Transformers's root logger.N)rDr,rLrFrhs r remove_handlerrks8#$  72J2L2U2U#UU U,,W5r"c6tdt_y)zk Disable propagation of the library log outputs. Note that log propagation is disabled by default. FNrDr,r@r(r"r disable_propagationrns #$+0(r"c6tdt_y)z Enable propagation of the library log outputs. Please disable the HuggingFace Transformers's default handler to prevent double logging if the root logger has been configured. TNrmr(r"r enable_propagationrp s #$+/(r"ctj}|D](}tjd}|j |*y)a Enable explicit formatting for every HuggingFace Transformers's logger. The explicit formatter is as follows: ``` [LEVELNAME|FILENAME|LINE NUMBER] TIME >> MESSAGE ``` All handlers currently bound to the root logger are affected by this method. zB[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)sN)r,rLrr=r>)rLrfrBs r enable_explicit_formatrrs@()22H(%%&jk Y'(r"c\tj}|D]}|jdy)z Resets the formatting for HuggingFace Transformers's loggers. All handlers currently bound to the root logger are affected by this method. N)r,rLr>)rLrfs r reset_formatrt%s/ ()22H#T"#r"cXtjd}|ry|j|i|y)z This method is identical to `logger.warning()`, but if env var TRANSFORMERS_NO_ADVISORY_WARNINGS=1 is set, this warning will not be printed !TRANSFORMERS_NO_ADVISORY_WARNINGSN)rrr)selfargskwargsno_advisory_warningss r warning_advicer{1s- 99%HIDLL$!&!r"c(|j|i|y)a This method is identical to `logger.warning()`, but will emit the warning with the same message only once Note: The cache is for the function arguments, so 2 different callers using the same arguments will hit the cache. The assumption here is that all warning messages are unique across the code. If they aren't then need to switch to another type of cache that includes the caller frame information in the hashing function. N)rrwrxrys r warning_oncer~?sDLL$!&!r"c(|j|i|y)a This method is identical to `logger.info()`, but will emit the info with the same message only once Note: The cache is for the function arguments, so 2 different callers using the same arguments will hit the cache. The assumption here is that all warning messages are unique across the code. If they aren't then need to switch to another type of cache that includes the caller frame information in the hashing function. N)rr}s r info_oncerNsDIItvr"c.eZdZdZdZdZdZdZdZy) EmptyTqdmz%Dummy tqdm which doesn't do anything.c,|r |d|_yd|_y)Nr) _iteratorr}s r __init__zEmptyTqdm.__init__`s$(adr"c,t|jSr+)iterrrws r __iter__zEmptyTqdm.__iter__csDNN##r"c d}|S)zReturn empty function.cyr+r()rxrys r empty_fnz'EmptyTqdm.__getattr__..empty_fnis r"r()rw_rs r __getattr__zEmptyTqdm.__getattr__fs r"c|Sr+r(rs r __enter__zEmptyTqdm.__enter__ns r"cyr+r()rwtype_value tracebacks r __exit__zEmptyTqdm.__exit__qsr"N) r& __module__ __qualname____doc__rrrrrr(r"r rr]s/3$r"rceZdZdZdZdZy) _tqdm_clscNtrtj|i|St|i|Sr+) _tqdm_activetqdm_libtqdmrr}s r __call__z_tqdm_cls.__call__vs) ==$1&1 1d-f- -r"c\d|_trtjj|i|Syr+)r4rrrset_lockr}s r rz_tqdm_cls.set_lock|s+ ==))4:6: : r"cLtrtjjSyr+)rrrget_lockrs r rz_tqdm_cls.get_locks ==))+ + r"N)r&rrrrrr(r"r rrus. ; ,r"rc ttS)zCReturn a boolean indicating whether tqdm progress bars are enabled.)boolrr(r"r is_progress_bar_enabledrs  r"c0datjy)zEnable tqdm progress bar.TN)r hf_hub_utilsenable_progress_barsr(r"r enable_progress_barrsL%%'r"c0datjy)zDisable tqdm progress bar.FN)rrdisable_progress_barsr(r"r disable_progress_barrsL&&(r")r#Nr+)Cr functoolsrrr6 threadingrrrrrrr r r rNtypingr huggingface_hub.utilsutilsrrr rLockr4rHandler__annotations__rrare_progress_bars_disabledrr!strr)Loggerr,rDrGrIrKintrUrXrZr\r^rarcrerirkrnrprrrtr{ lru_cacher~rrrrrrrr(r"r rs!    8,!  .2(7??+2mm ]] LL ]]   __:<::<< ""3"2'..2.6  . #Xc] #gnn #:s:.3S3T3& "   ?<33T36GOO6610 ( #"!/T""+T%0,,"{ ()r"