

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    :       Tuple        =							threading.Lock()
_lowerCamelCase    :       Optional[logging.Handler]        =							None

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

_lowerCamelCase    :       List[Any]        =							logging.WARNING

_lowerCamelCase    :       List[Any]        =							True

def       a__					(		)  ->						int:
		UpperCAmelCase	:							Optional[Any]						=			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__					(		)  ->						str:
		return __name__.split('''.'''      )[0]

def       a__					(		)  ->						logging.Logger:
		return logging.getLogger(_get_library_name()      )

def       a__					(		)  ->						None:
		global _default_handler

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

				# Apply our default configuration to the library root logger.
				UpperCAmelCase	:							Tuple						=			_get_library_root_logger()
				library_root_logger.addHandler(_default_handler      )
				library_root_logger.setLevel(_get_default_logging_level()      )
				UpperCAmelCase	:							Optional[int]						=			False

def       a__					(		)  ->						None:
		global _default_handler

		with _lock:
				if not _default_handler:
						return

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

def       a__					(		)  ->						str:
		return log_levels

def       a__					(		UpperCAmelCase							:      Optional[str] = None      )  ->						logging.Logger:


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

		_configure_library_root_logger()
		return logging.getLogger(lowerCAmelCase__      )

def       a__					(		)  ->						int:
		_configure_library_root_logger()
		return _get_library_root_logger().getEffectiveLevel()

def       a__					(		UpperCAmelCase							:      int      )  ->						None:
		_configure_library_root_logger()
		_get_library_root_logger().setLevel(lowerCAmelCase__      )

def       a__					(		)  ->						Union[str, Any]:
		return set_verbosity(lowerCAmelCase__      )

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

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

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

def       a__					(		)  ->						None:
		_configure_library_root_logger()

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

def       a__					(		)  ->						None:
		_configure_library_root_logger()

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

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

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

def       a__					(		UpperCAmelCase							:      logging.Handler      )  ->						None:
		_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__					(		)  ->						None:
		_configure_library_root_logger()
		UpperCAmelCase	:							Tuple						=			False

def       a__					(		)  ->						None:
		_configure_library_root_logger()
		UpperCAmelCase	:							Tuple						=			True

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

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

def       a__					(		)  ->						None:
		UpperCAmelCase	:							List[Any]						=			_get_library_root_logger().handlers

		for handler in handlers:
				handler.setFormatter(lowerCAmelCase__      )

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


_lowerCamelCase    :       Optional[int]        =							warning_advice

@functools.lru_cache(lowerCAmelCase__      )
def       a__					(		self							:      Union[str, Any]    ,			*UpperCAmelCase							:      List[str]    ,			**UpperCAmelCase							:      Dict      )  ->						Union[str, Any]:
		self.warning(*lowerCAmelCase__    ,			**lowerCAmelCase__      )


_lowerCamelCase    :       int        =							warning_once





class  __UpperCAmelCase					:



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



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



			def __getattr__(							self							:					Dict,		__A							:					int						):



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

					return empty_fn



			def __enter__(							self							:					str						):
					return self





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






class  __UpperCAmelCase					:



			def __call__(							self							:					Any,		*__A							:					Any,		**__A							:					Dict						):



					if _tqdm_active:
							return tqdm_lib.tqdm(*__lowerCAmelCase,		**__lowerCAmelCase						)
					else:
							return EmptyTqdm(*__lowerCAmelCase,		**__lowerCAmelCase						)



			def 	__magic_name__   (							self							:					Optional[int],		*__A							:					List[Any],		**__A							:					Dict						):
					UpperCAmelCase	:							Any						=			None
					if _tqdm_active:
							return tqdm_lib.tqdm.set_lock(*__lowerCAmelCase,		**__lowerCAmelCase						)





			def 	__magic_name__   (							self							:					List[Any]						):



					if _tqdm_active:
							return tqdm_lib.tqdm.get_lock()






_lowerCamelCase    :       Optional[int]        =							_tqdm_cls()

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

def       a__					(		)  ->						Dict:
		global _tqdm_active
		UpperCAmelCase	:							int						=			True
		hf_hub_utils.enable_progress_bars()






def       a__					(		)  ->						Tuple:
		global _tqdm_active
		UpperCAmelCase	:							Tuple						=			False
		hf_hub_utils.disable_progress_bars()








def       a__					(		UpperCAmelCase							:      int      )  ->						bool:
  if not isinstance(UpperCAmelCase    ,			UpperCAmelCase      ):
    UpperCAmelCase	:							List[str]						=			f'''Input value of [number={number}] must be an integer'''
    raise TypeError(UpperCAmelCase      )
  if number < 0:
    return False
  UpperCAmelCase	:							List[str]						=			number * number
  while number > 0:
    if number % 10 != number_square % 10:
      return False
    number //= 10
    number_square //= 10
  return True


if __name__ == "__main__":
     import doctest

     doctest.testmod()





