

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


SCREAMING_SNAKE_CASE__     :    Dict      							=					threading.Lock()
SCREAMING_SNAKE_CASE__     :    Optional[logging.Handler]      							=					None

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

SCREAMING_SNAKE_CASE__     :    List[Any]      							=					logging.WARNING

SCREAMING_SNAKE_CASE__     :    Union[str, Any]      							=					True




def 				__magic_name__				(     )    ->     Union[str, Any]:
				__lowerCamelCase					      =			os.getenv('''DIFFUSERS_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 DIFFUSERS_VERBOSITY={env_level_str}, '''
												    f'''has to be one of: { ', '.join(log_levels.keys()							) }'''							)
				return _default_log_level




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




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




def 				__magic_name__				(     )    ->     None:
				global _default_handler

				with _lock:
								if _default_handler:
												# This library has already configured the library root logger.
												return
								__lowerCamelCase					      =			logging.StreamHandler()  # Set sys.stderr as stream.
								__lowerCamelCase					      =			sys.stderr.flush

								# Apply our default configuration to the library root logger.
								__lowerCamelCase					      =			_get_library_root_logger()
								library_root_logger.addHandler(_default_handler							)
								library_root_logger.setLevel(_get_default_logging_level()							)
								__lowerCamelCase					      =			False




def 				__magic_name__				(     )    ->     None:
				global _default_handler

				with _lock:
								if not _default_handler:
												return

								__lowerCamelCase					      =			_get_library_root_logger()
								library_root_logger.removeHandler(_default_handler							)
								library_root_logger.setLevel(logging.NOTSET							)
								__lowerCamelCase					      =			None




def 				__magic_name__				(     )    ->     Union[str, Any]:
				return log_levels




def 				__magic_name__				(     __lowerCAmelCase			:		Optional[str] = None							)    ->     logging.Logger:

				if name is None:
								__lowerCamelCase					      =			_get_library_name()

				_configure_library_root_logger()
				return logging.getLogger(__lowerCAmelCase							)




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




def 				__magic_name__				(     __lowerCAmelCase			:		int							)    ->     None:
				_configure_library_root_logger()
				_get_library_root_logger().setLevel(__lowerCAmelCase							)




def 				__magic_name__				(     )    ->     Dict:
				return set_verbosity(__lowerCAmelCase							)




def 				__magic_name__				(     )    ->     Tuple:
				return set_verbosity(__lowerCAmelCase							)




def 				__magic_name__				(     )    ->     Any:
				return set_verbosity(__lowerCAmelCase							)




def 				__magic_name__				(     )    ->     Tuple:
				return set_verbosity(__lowerCAmelCase							)




def 				__magic_name__				(     )    ->     None:
				_configure_library_root_logger()

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




def 				__magic_name__				(     )    ->     None:
				_configure_library_root_logger()

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




def 				__magic_name__				(     __lowerCAmelCase			:		logging.Handler							)    ->     None:
				_configure_library_root_logger()

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




def 				__magic_name__				(     __lowerCAmelCase			:		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 				__magic_name__				(     )    ->     None:
				_configure_library_root_logger()
				__lowerCamelCase					      =			False




def 				__magic_name__				(     )    ->     None:
				_configure_library_root_logger()
				__lowerCamelCase					      =			True




def 				__magic_name__				(     )    ->     None:
				__lowerCamelCase					      =			_get_library_root_logger().handlers

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




def 				__magic_name__				(     )    ->     None:
				__lowerCamelCase					      =			_get_library_root_logger().handlers

				for handler in handlers:
								handler.setFormatter(__lowerCAmelCase							)




def 				__magic_name__				(     self			:		Any	,						*__lowerCAmelCase			:		List[Any]	,						**__lowerCAmelCase			:		str							)    ->     Optional[Any]:
				__lowerCamelCase					      =			os.getenv('''DIFFUSERS_NO_ADVISORY_WARNINGS'''	,						__lowerCAmelCase							)
				if no_advisory_warnings:
								return
				self.warning(*__lowerCAmelCase	,						**__lowerCAmelCase							)


SCREAMING_SNAKE_CASE__     :    Dict      							=					warning_advice

class      lowerCAmelCase__  :






		def __init__(	self	:							Union[str, Any]							,    *SCREAMING_SNAKE_CASE__	:							Union[str, Any]							,    **SCREAMING_SNAKE_CASE__	:							Optional[Any]						)  ->							Optional[int]:  # pylint: disable=unused-argument
						__lowerCamelCase					      =			args[0] if args else None






		def __iter__(	self	:							List[str]						)  ->							Union[str, Any]:
						return iter(self._iterator						)






		def __getattr__(	self	:							List[str]							,    SCREAMING_SNAKE_CASE__	:							int						)  ->							Optional[Any]:

						def empty_fn(*SCREAMING_SNAKE_CASE__	:							Optional[Any]							,    **SCREAMING_SNAKE_CASE__	:							List[Any]						):  # pylint: disable=unused-argument
										return

						return empty_fn






		def __enter__(	self	:							List[Any]						)  ->							Optional[int]:
						return self







		def __exit__(	self	:							Dict							,    SCREAMING_SNAKE_CASE__	:							int							,    SCREAMING_SNAKE_CASE__	:							List[str]							,    SCREAMING_SNAKE_CASE__	:							List[Any]						)  ->							Optional[int]:
						return





class      lowerCAmelCase__  :






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






		def 				__A (	self	:							Union[str, Any]							,    *SCREAMING_SNAKE_CASE__	:							str							,    **SCREAMING_SNAKE_CASE__	:							Tuple						)  ->							Optional[Any]:
						__lowerCamelCase					      =			None
						if _tqdm_active:
										return tqdm_lib.tqdm.set_lock(*SCREAMING_SNAKE_CASE__							,    **SCREAMING_SNAKE_CASE__						)







		def 				__A (	self	:							Any						)  ->							Any:
						if _tqdm_active:
										return tqdm_lib.tqdm.get_lock()





SCREAMING_SNAKE_CASE__     :    str      							=					_tqdm_cls()




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




def 				__magic_name__				(     )    ->     Dict:
				global _tqdm_active
				__lowerCamelCase					      =			True







def 				__magic_name__				(     )    ->     List[str]:
				global _tqdm_active
				__lowerCamelCase					      =			False





from ..utils import requires_backends


SCREAMING_SNAKE_CASE__     :    Union[str, Any]      							=					None

class      lowerCAmelCase__  :






		def __init__(	self	:							int							,    *SCREAMING_SNAKE_CASE__	:							Dict							,    **SCREAMING_SNAKE_CASE__	:							Tuple						)  ->							Optional[Any]:
						requires_backends(self							,    ['''detectron2''']						)







		@classmethod
		def 				__A (	cls	:							Dict							,    *SCREAMING_SNAKE_CASE__	:							Dict							,    **SCREAMING_SNAKE_CASE__	:							Tuple						)  ->							Tuple:
						requires_backends(cls							,    ['''detectron2''']						)



