

import functools
import logging
import os
import sys
import threading
from logging import (
    CRITICAL,  # NOQA
    DEBUG,  # NOQA
    ERROR,  # NOQA
    FATAL,  # NOQA
    INFO,  # NOQA
    NOTSET,  # NOQA
    WARN,  # NOQA
    WARNING,  # NOQA
)
from typing import Optional

import huggingface_hub.utils as hf_hub_utils
from tqdm import auto as tqdm_lib


_lowerCamelCase    :       Any        =							threading.Lock()
_lowerCamelCase    :       List[Any]        =							None

_lowerCamelCase    :       Optional[Any]        =							{
    "debug": logging.DEBUG,
    "info": logging.INFO,
    "warning": logging.WARNING,
    "error": logging.ERROR,
    "critical": logging.CRITICAL,
}

_lowerCamelCase    :       Tuple        =							logging.WARNING

_lowerCamelCase    :       Dict        =							True

def       a__					(		)  ->						Optional[int]:
  UpperCAmelCase	:							Dict						=			os.getenv('''TRANSFORMERS_VERBOSITY'''    ,			lowerCAmelCase__      )
  if env_level_str:
    if env_level_str in log_levels:
      return log_levels[env_level_str]
    else:
      logging.getLogger().warning(
          f'''Unknown option TRANSFORMERS_VERBOSITY={env_level_str}, '''
          f'''has to be one of: { ", ".join(log_levels.keys()      ) }'''      )
  return _default_log_level

def       a__					(		)  ->						List[str]:
  return __name__.split('''.'''      )[0]

def       a__					(		)  ->						List[str]:
  return logging.getLogger(_get_library_name()      )

def       a__					(		)  ->						List[Any]:
  global _default_handler

  with _lock:
    if _default_handler:
      # This library has already configured the library root logger.
      return
    UpperCAmelCase	:							str						=			logging.StreamHandler()  # Set sys.stderr as stream.
    UpperCAmelCase	:							Union[str, Any]						=			sys.stderr.flush

    # Apply our default configuration to the library root logger.
    UpperCAmelCase	:							Union[str, Any]						=			_get_library_root_logger()
    library_root_logger.addHandler(_default_handler      )
    library_root_logger.setLevel(_get_default_logging_level()      )
    UpperCAmelCase	:							Union[str, Any]						=			False

def       a__					(		)  ->						Union[str, Any]:
  global _default_handler

  with _lock:
    if not _default_handler:
      return

    UpperCAmelCase	:							Optional[Any]						=			_get_library_root_logger()
    library_root_logger.removeHandler(_default_handler      )
    library_root_logger.setLevel(logging.NOTSET      )
    UpperCAmelCase	:							str						=			None

def       a__					(		)  ->						str:
  return log_levels

def       a__					(		UpperCAmelCase							:      Optional[str] = None      )  ->						int:

  if name is None:
    UpperCAmelCase	:							str						=			_get_library_name()

  _configure_library_root_logger()
  return logging.getLogger(lowerCAmelCase__      )

def       a__					(		)  ->						List[str]:
  _configure_library_root_logger()
  return _get_library_root_logger().getEffectiveLevel()

def       a__					(		UpperCAmelCase							:      int      )  ->						Optional[int]:
  _configure_library_root_logger()
  _get_library_root_logger().setLevel(lowerCAmelCase__      )

def       a__					(		)  ->						Optional[Any]:
  return set_verbosity(lowerCAmelCase__      )

def       a__					(		)  ->						Optional[Any]:
  return set_verbosity(lowerCAmelCase__      )

def       a__					(		)  ->						int:
  return set_verbosity(lowerCAmelCase__      )

def       a__					(		)  ->						Dict:
  return set_verbosity(lowerCAmelCase__      )

def       a__					(		)  ->						Optional[Any]:
  _configure_library_root_logger()

  assert _default_handler is not None
  _get_library_root_logger().removeHandler(_default_handler      )

def       a__					(		)  ->						Any:
  _configure_library_root_logger()

  assert _default_handler is not None
  _get_library_root_logger().addHandler(_default_handler      )

def       a__					(		UpperCAmelCase							:      logging.Handler      )  ->						int:
  _configure_library_root_logger()

  assert handler is not None
  _get_library_root_logger().addHandler(lowerCAmelCase__      )

def       a__					(		UpperCAmelCase							:      logging.Handler      )  ->						Any:
  _configure_library_root_logger()

  assert handler is not None and handler not in _get_library_root_logger().handlers
  _get_library_root_logger().removeHandler(lowerCAmelCase__      )

def       a__					(		)  ->						List[str]:
  _configure_library_root_logger()
  UpperCAmelCase	:							Tuple						=			False

def       a__					(		)  ->						str:
  _configure_library_root_logger()
  UpperCAmelCase	:							Dict						=			True

def       a__					(		)  ->						int:
  UpperCAmelCase	:							Optional[Any]						=			_get_library_root_logger().handlers

  for handler in handlers:
    UpperCAmelCase	:							Optional[int]						=			logging.Formatter('''[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s'''      )
    handler.setFormatter(lowerCAmelCase__      )

def       a__					(		)  ->						int:
  UpperCAmelCase	:							Tuple						=			_get_library_root_logger().handlers

  for handler in handlers:
    handler.setFormatter(lowerCAmelCase__      )

def       a__					(		self							:      List[Any]    ,			*UpperCAmelCase							:      List[str]    ,			**UpperCAmelCase							:      Optional[int]      )  ->						Optional[int]:
  UpperCAmelCase	:							Union[str, Any]						=			os.getenv('''TRANSFORMERS_NO_ADVISORY_WARNINGS'''    ,			lowerCAmelCase__      )
  if no_advisory_warnings:
    return
  self.warning(*lowerCAmelCase__    ,			**lowerCAmelCase__      )


_lowerCamelCase    :       Dict        =							warning_advice

@functools.lru_cache(lowerCAmelCase__      )
def       a__					(		self							:      Any    ,			*UpperCAmelCase							:      Optional[Any]    ,			**UpperCAmelCase							:      Any      )  ->						int:
  self.warning(*lowerCAmelCase__    ,			**lowerCAmelCase__      )


_lowerCamelCase    :       Optional[int]        =							warning_once





class  SCREAMING_SNAKE_CASE					:



   def __init__(							self							:					List[Any],		*__A							:					Any,		**__A							:					List[Any]						):  # pylint: disable=unused-argument
     UpperCAmelCase	:							Optional[int]						=			args[0] if args else None



   def __iter__(							self							:					Dict						):
     return iter(self._iterator						)



   def __getattr__(							self							:					List[str],		__A							:					List[Any]						):

     def empty_fn(*__A							:					Tuple,		**__A							:					Union[str, Any]						):  # pylint: disable=unused-argument
       return

     return empty_fn



   def __enter__(							self							:					Union[str, Any]						):
     return self





   def __exit__(							self							:					Tuple,		__A							:					List[Any],		__A							:					List[str],		__A							:					List[str]						):
     return






class  SCREAMING_SNAKE_CASE					:



   def __call__(							self							:					List[Any],		*__A							:					List[str],		**__A							:					List[Any]						):
     if _tqdm_active:
       return tqdm_lib.tqdm(*snake_case_,		**snake_case_						)
     else:
       return EmptyTqdm(*snake_case_,		**snake_case_						)



   def 	__magic_name__   (							self							:					str,		*__A							:					Any,		**__A							:					List[Any]						):
     UpperCAmelCase	:							str						=			None
     if _tqdm_active:
       return tqdm_lib.tqdm.set_lock(*snake_case_,		**snake_case_						)





   def 	__magic_name__   (							self							:					str						):
     if _tqdm_active:
       return tqdm_lib.tqdm.get_lock()






_lowerCamelCase    :       Union[str, Any]        =							_tqdm_cls()

def       a__					(		)  ->						Any:
  global _tqdm_active
  return bool(_tqdm_active      )

def       a__					(		)  ->						Any:
  global _tqdm_active
  UpperCAmelCase	:							str						=			True
  hf_hub_utils.enable_progress_bars()






def       a__					(		)  ->						Dict:
  global _tqdm_active
  UpperCAmelCase	:							Optional[int]						=			False
  hf_hub_utils.disable_progress_bars()








from ..utils import DummyObject, requires_backends





class  __UpperCAmelCase					(	metaclass=lowerCamelCase__						):
   UpperCamelCase       					=					["""onnx"""]



   def __init__(							self							:					int,		*__A							:					Optional[Any],		**__A							:					Dict						):
     requires_backends(self,		['''onnx''']						)



   @classmethod
   def 	__magic_name__   (							cls							:					Any,		*__A							:					Any,		**__A							:					Dict						):
     requires_backends(cls,		['''onnx''']						)





   @classmethod
   def 	__magic_name__   (							cls							:					Tuple,		*__A							:					List[str],		**__A							:					List[str]						):
     requires_backends(cls,		['''onnx''']						)





