



'''simple docstring'''



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

from tqdm import auto as tqdm_lib


_lowercase       :						Optional[Any]						=threading.Lock()
_lowercase       :						Optional[logging.Handler]						=None

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

_lowercase       :						Union[str, Any]						=logging.WARNING

_lowercase       :						Optional[Any]						=True


def 							__UpperCAmelCase				(				)		->						Optional[Any]:
				snake_case__      :   Union[str, Any]      =    os.getenv('''DIFFUSERS_VERBOSITY'''   ,				UpperCamelCase__			)
				if env_level_str:
								if env_level_str in log_levels:
												return log_levels[env_level_str]
								else:
												logging.getLogger().warning(
												    F'''Unknown option DIFFUSERS_VERBOSITY={env_level_str}, '''
												    F'''has to be one of: { ", ".join(log_levels.keys()			) }'''			)
				return _default_log_level


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


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


def 							__UpperCAmelCase				(				)		->						None:
				global _default_handler

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

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


def 							__UpperCAmelCase				(				)		->						None:
				global _default_handler

				with _lock:
								if not _default_handler:
												return

								snake_case__      :   Any      =    _get_library_root_logger()
								library_root_logger.removeHandler(_default_handler			)
								library_root_logger.setLevel(logging.NOTSET			)
								snake_case__      :   Any      =    None


def 							__UpperCAmelCase				(				)		->						Optional[int]:
				return log_levels


def 							__UpperCAmelCase				(				UpperCamelCase__				:Optional[str] = None			)		->						logging.Logger:

				if name is None:
								snake_case__      :   Any      =    _get_library_name()

				_configure_library_root_logger()
				return logging.getLogger(UpperCamelCase__			)


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


def 							__UpperCAmelCase				(				UpperCamelCase__				:int			)		->						None:
				_configure_library_root_logger()
				_get_library_root_logger().setLevel(UpperCamelCase__			)


def 							__UpperCAmelCase				(				)		->						Optional[Any]:
				return set_verbosity(UpperCamelCase__			)


def 							__UpperCAmelCase				(				)		->						Union[str, Any]:
				return set_verbosity(UpperCamelCase__			)


def 							__UpperCAmelCase				(				)		->						Dict:
				return set_verbosity(UpperCamelCase__			)


def 							__UpperCAmelCase				(				)		->						Any:
				return set_verbosity(UpperCamelCase__			)


def 							__UpperCAmelCase				(				)		->						None:
				_configure_library_root_logger()

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


def 							__UpperCAmelCase				(				)		->						None:
				_configure_library_root_logger()

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


def 							__UpperCAmelCase				(				UpperCamelCase__				:logging.Handler			)		->						None:
				_configure_library_root_logger()

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


def 							__UpperCAmelCase				(				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(UpperCamelCase__			)


def 							__UpperCAmelCase				(				)		->						None:
				_configure_library_root_logger()
				snake_case__      :   Any      =    False


def 							__UpperCAmelCase				(				)		->						None:
				_configure_library_root_logger()
				snake_case__      :   Dict      =    True


def 							__UpperCAmelCase				(				)		->						None:
				snake_case__      :   List[str]      =    _get_library_root_logger().handlers

				for handler in handlers:
								snake_case__      :   Union[str, Any]      =    logging.Formatter('''[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s >> %(message)s'''			)
								handler.setFormatter(UpperCamelCase__			)


def 							__UpperCAmelCase				(				)		->						None:
				snake_case__      :   Dict      =    _get_library_root_logger().handlers

				for handler in handlers:
								handler.setFormatter(UpperCamelCase__			)


def 							__UpperCAmelCase				(				self				:Optional[Any]   ,				*UpperCamelCase__				:Optional[Any]   ,				**UpperCamelCase__				:Dict			)		->						Dict:
				snake_case__      :   List[Any]      =    os.getenv('''DIFFUSERS_NO_ADVISORY_WARNINGS'''   ,				UpperCamelCase__			)
				if no_advisory_warnings:
								return
				self.warning(*UpperCamelCase__   ,				**UpperCamelCase__			)


_lowercase       :						Dict						=warning_advice






class 			_SCREAMING_SNAKE_CASE				:



			def __init__(     self		:						List[Any]    ,			*__UpperCamelCase		:						Any    ,			**__UpperCamelCase		:						Optional[Any]			)      ->      Union[str, Any]:  # pylint: disable=unused-argument
							"""simple docstring"""





							snake_case__      :   Union[str, Any]      =    args[0] if args else None



			def __iter__(     self		:						Optional[int]			)      ->      List[Any]:
							"""simple docstring"""





							return iter(self._iterator			)



			def __getattr__(     self		:						Optional[Any]    ,			__UpperCamelCase		:						str			)      ->      Optional[Any]:
							"""simple docstring"""





							def empty_fn(*__UpperCamelCase		:						int    ,			**__UpperCamelCase		:						Optional[int]			):  # pylint: disable=unused-argument
											return

							return empty_fn



			def __enter__(     self		:						int			)      ->      List[str]:
							"""simple docstring"""





							return self







			def __exit__(     self		:						Union[str, Any]    ,			__UpperCamelCase		:						Union[str, Any]    ,			__UpperCamelCase		:						Tuple    ,			__UpperCamelCase		:						Tuple			)      ->      List[str]:
							"""simple docstring"""





							return






class 			_SCREAMING_SNAKE_CASE				:



			def __call__(     self		:						List[Any]    ,			*__UpperCamelCase		:						str    ,			**__UpperCamelCase		:						List[Any]			)      ->      Optional[Any]:
							"""simple docstring"""





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



			def 				lowerCAmelCase (     self		:						int    ,			*__UpperCamelCase		:						Union[str, Any]    ,			**__UpperCamelCase		:						str			)      ->      Any:
							"""simple docstring"""





							snake_case__      :   Dict      =    None
							if _tqdm_active:
											return tqdm_lib.tqdm.set_lock(*__UpperCamelCase    ,			**__UpperCamelCase			)







			def 				lowerCAmelCase (     self		:						int			)      ->      Optional[Any]:
							"""simple docstring"""





							if _tqdm_active:
											return tqdm_lib.tqdm.get_lock()



_lowercase       :						Optional[int]						=_tqdm_cls()


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


def 							__UpperCAmelCase				(				)		->						List[str]:
				global _tqdm_active
				snake_case__      :   Dict      =    True



def 							__UpperCAmelCase				(				)		->						str:
				global _tqdm_active
				snake_case__      :   Any      =    False








a					:				Tuple       =      [0.4_85, 0.4_56, 0.4_06]
a					:				Optional[int]       =      [0.2_29, 0.2_24, 0.2_25]
a					:				List[Any]       =      [0.5, 0.5, 0.5]
a					:				Tuple       =      [0.5, 0.5, 0.5]
a					:				Optional[Any]       =      [0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73]
a					:				int       =      [0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11]






