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


A__           =							threading.Lock()
A__           =							None

A__           =							{
    """debug""": logging.DEBUG,
    """info""": logging.INFO,
    """warning""": logging.WARNING,
    """error""": logging.ERROR,
    """critical""": logging.CRITICAL,
}

A__           =							logging.WARNING

A__           =							True





def  _lowerCamelCase					(   ):
			lowerCamelCase						:Tuple						  =     os.getenv('''TRANSFORMERS_VERBOSITY'''						,			a_)
			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  _lowerCamelCase					(   ):
			return __name__.split('''.''')[0]





def  _lowerCamelCase					(   ):
			return logging.getLogger(_get_library_name())





def  _lowerCamelCase					(   ):
			global _default_handler

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

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





def  _lowerCamelCase					(   ):
			global _default_handler

			with _lock:
						if not _default_handler:
									return

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





def  _lowerCamelCase					(   ):
			return log_levels





def  _lowerCamelCase					(   a_				: Optional[str] = None):

			if name is None:
						lowerCamelCase						:List[Any]						  =     _get_library_name()

			_configure_library_root_logger()
			return logging.getLogger(a_)





def  _lowerCamelCase					(   ):
			_configure_library_root_logger()
			return _get_library_root_logger().getEffectiveLevel()





def  _lowerCamelCase					(   a_				: int):
			_configure_library_root_logger()
			_get_library_root_logger().setLevel(a_)





def  _lowerCamelCase					(   ):
			return set_verbosity(a_)





def  _lowerCamelCase					(   ):
			return set_verbosity(a_)





def  _lowerCamelCase					(   ):
			return set_verbosity(a_)





def  _lowerCamelCase					(   ):
			return set_verbosity(a_)





def  _lowerCamelCase					(   ):
			_configure_library_root_logger()

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





def  _lowerCamelCase					(   ):
			_configure_library_root_logger()

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





def  _lowerCamelCase					(   a_				: logging.Handler):
			_configure_library_root_logger()

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





def  _lowerCamelCase					(   a_				: logging.Handler):
			_configure_library_root_logger()

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





def  _lowerCamelCase					(   ):
			_configure_library_root_logger()
			lowerCamelCase						:List[str]						  =     False





def  _lowerCamelCase					(   ):
			_configure_library_root_logger()
			lowerCamelCase						:str						  =     True





def  _lowerCamelCase					(   ):
			lowerCamelCase						:Union[str, Any]						  =     _get_library_root_logger().handlers

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





def  _lowerCamelCase					(   ):
			lowerCamelCase						:Optional[Any]						  =     _get_library_root_logger().handlers

			for handler in handlers:
						handler.setFormatter(a_)





def  _lowerCamelCase					(   self				: Optional[int]						,			*a_				: str						,			**a_				: List[Any]):
			lowerCamelCase						:str						  =     os.getenv('''TRANSFORMERS_NO_ADVISORY_WARNINGS'''						,			a_)
			if no_advisory_warnings:
						return
			self.warning(*a_						,			**a_)


A__           =							warning_advice





@functools.lru_cache(a_)
def  _lowerCamelCase					(   self				: int						,			*a_				: Union[str, Any]						,			**a_				: Optional[Any]):
			self.warning(*a_						,			**a_)


A__           =							warning_once
class   _lowerCAmelCase		:







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







							def __iter__(				self     :    Optional[int]		):
										return iter(self._iterator		)







							def __getattr__(				self     :    Optional[int]	,					__snake_case     :    Dict		):

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

										return empty_fn







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







							def __exit__(				self     :    Optional[int]	,					__snake_case     :    Any	,					__snake_case     :    List[str]	,					__snake_case     :    Optional[Any]		):
										return


class   _lowerCAmelCase		:







							def __call__(				self     :    Optional[int]	,					*__snake_case     :    Dict	,					**__snake_case     :    Optional[Any]		):
										if _tqdm_active:
													return tqdm_lib.tqdm(*__snake_case	,					**__snake_case		)
										else:
													return EmptyTqdm(*__snake_case	,					**__snake_case		)







							def 				snake_case  (				self     :    int	,					*__snake_case     :    Union[str, Any]	,					**__snake_case     :    Union[str, Any]		):
										lowerCamelCase						:Union[str, Any]						  =     None
										if _tqdm_active:
													return tqdm_lib.tqdm.set_lock(*__snake_case	,					**__snake_case		)







							def 				snake_case  (				self     :    Tuple		):
										if _tqdm_active:
													return tqdm_lib.tqdm.get_lock()


A__           =							_tqdm_cls()





def  _lowerCamelCase					(   ):
			global _tqdm_active
			return bool(_tqdm_active)





def  _lowerCamelCase					(   ):
			global _tqdm_active
			lowerCamelCase						:List[str]						  =     True
			hf_hub_utils.enable_progress_bars()





def  _lowerCamelCase					(   ):
			global _tqdm_active
			lowerCamelCase						:List[Any]						  =     False
			hf_hub_utils.disable_progress_bars()




from maths.prime_factors import prime_factors





def  _lowerCamelCase					(   a_				: int):
			if not isinstance(a_						,			a_):
						lowerCamelCase						:Tuple						  =     F"Input value of [number={number}] must be an integer"
						raise TypeError(a_)
			if number < 1:
						raise ValueError('''Input must be a positive integer''')
			return -1 if len(prime_factors(a_)) % 2 else 1


if __name__ == "__main__":
			import doctest

			doctest.testmod()



