






"""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


__A		:	Tuple      =		threading.Lock()
__A		:	Optional[logging.Handler]      =		None

__A		:	Dict      =		{
    '''debug''': logging.DEBUG,
    '''info''': logging.INFO,
    '''warning''': logging.WARNING,
    '''error''': logging.ERROR,
    '''critical''': logging.CRITICAL,
}

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

__A		:	List[str]      =		True



def 						lowercase   (    ):
		lowercase_			:			Tuple								=       os.getenv('''DIFFUSERS_VERBOSITY'''		, __snake_case     )
		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 						lowercase   (    ):
		return __name__.split('''.'''     )[0]



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



def 						lowercase   (    ):
		global _default_handler

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

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



def 						lowercase   (    ):
		global _default_handler

		with _lock:
				if not _default_handler:
						return

				lowercase_			:			Union[str, Any]								=       _get_library_root_logger()
				library_root_logger.removeHandler(_default_handler     )
				library_root_logger.setLevel(logging.NOTSET     )
				lowercase_			:			Union[str, Any]								=       None



def 						lowercase   (    ):
		return log_levels



def 						lowercase   (    __snake_case    :			Optional[str] = None     ):

		if name is None:
				lowercase_			:			Optional[int]								=       _get_library_name()

		_configure_library_root_logger()
		return logging.getLogger(__snake_case     )



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



def 						lowercase   (    __snake_case    :			int     ):
		_configure_library_root_logger()
		_get_library_root_logger().setLevel(__snake_case     )



def 						lowercase   (    ):
		return set_verbosity(__snake_case     )



def 						lowercase   (    ):
		return set_verbosity(__snake_case     )



def 						lowercase   (    ):
		return set_verbosity(__snake_case     )



def 						lowercase   (    ):
		return set_verbosity(__snake_case     )



def 						lowercase   (    ):
		_configure_library_root_logger()

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



def 						lowercase   (    ):
		_configure_library_root_logger()

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



def 						lowercase   (    __snake_case    :			logging.Handler     ):
		_configure_library_root_logger()

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



def 						lowercase   (    __snake_case    :			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(__snake_case     )



def 						lowercase   (    ):
		_configure_library_root_logger()
		lowercase_			:			Any								=       False



def 						lowercase   (    ):
		_configure_library_root_logger()
		lowercase_			:			Tuple								=       True



def 						lowercase   (    ):
		lowercase_			:			Tuple								=       _get_library_root_logger().handlers

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



def 						lowercase   (    ):
		lowercase_			:			Dict								=       _get_library_root_logger().handlers

		for handler in handlers:
				handler.setFormatter(__snake_case     )



def 						lowercase   (    self    :			Optional[int]		, *__snake_case    :			Optional[Any]		, **__snake_case    :			List[Any]     ):
		lowercase_			:			List[Any]								=       os.getenv('''DIFFUSERS_NO_ADVISORY_WARNINGS'''		, __snake_case     )
		if no_advisory_warnings:
				return
		self.warning(*__snake_case		, **__snake_case     )


__A		:	List[Any]      =		warning_advice





class  _UpperCAmelCase	:




					def __init__(    self					:						Any   ,						*A					:						int   ,						**A					:						Dict       )  ->  Dict:  # pylint: disable=unused-argument
							lowercase_			:			Dict								=       args[0] if args else None




					def __iter__(    self					:						List[Any]       )  ->  Optional[int]:
							return iter(self._iterator       )




					def __getattr__(    self					:						List[str]   ,						A					:						Tuple       )  ->  Tuple:

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

							return empty_fn




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






					def __exit__(    self					:						Union[str, Any]   ,						A					:						List[str]   ,						A					:						Union[str, Any]   ,						A					:						Dict       )  ->  str:
							return





class  _UpperCAmelCase	:




					def __call__(    self					:						Any   ,						*A					:						Tuple   ,						**A					:						Any       )  ->  Tuple:
							if _tqdm_active:
									return tqdm_lib.tqdm(*A   ,						**A       )
							else:
									return EmptyTqdm(*A   ,						**A       )




					def   A  (    self					:						List[Any]   ,						*A					:						str   ,						**A					:						Optional[Any]       )  ->  int:
							lowercase_			:			Union[str, Any]								=       None
							if _tqdm_active:
									return tqdm_lib.tqdm.set_lock(*A   ,						**A       )






					def   A  (    self					:						Optional[Any]       )  ->  Optional[int]:
							if _tqdm_active:
									return tqdm_lib.tqdm.get_lock()
__A		:	Tuple      =		_tqdm_cls()



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



def 						lowercase   (    ):
		global _tqdm_active
		lowercase_			:			Optional[int]								=       True






def 						lowercase   (    ):
		global _tqdm_active
		lowercase_			:			Tuple								=       False











"""simple docstring"""



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


__A		:	Any      =		{
    '''configuration_markuplm''': ['''MARKUPLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MarkupLMConfig'''],
    '''feature_extraction_markuplm''': ['''MarkupLMFeatureExtractor'''],
    '''processing_markuplm''': ['''MarkupLMProcessor'''],
    '''tokenization_markuplm''': ['''MarkupLMTokenizer'''],
}

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:	List[str]      =		['''MarkupLMTokenizerFast''']

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:	Optional[int]      =		[
						    '''MARKUPLM_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''MarkupLMForQuestionAnswering''',
						    '''MarkupLMForSequenceClassification''',
						    '''MarkupLMForTokenClassification''',
						    '''MarkupLMModel''',
						    '''MarkupLMPreTrainedModel''',
						]


if TYPE_CHECKING:
						from .configuration_markuplm import MARKUPLM_PRETRAINED_CONFIG_ARCHIVE_MAP, MarkupLMConfig
						from .feature_extraction_markuplm import MarkupLMFeatureExtractor
						from .processing_markuplm import MarkupLMProcessor
						from .tokenization_markuplm import MarkupLMTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_markuplm_fast import MarkupLMTokenizerFast

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_markuplm import (
												    MARKUPLM_PRETRAINED_MODEL_ARCHIVE_LIST,
												    MarkupLMForQuestionAnswering,
												    MarkupLMForSequenceClassification,
												    MarkupLMForTokenClassification,
												    MarkupLMModel,
												    MarkupLMPreTrainedModel,
												)


else:
						import sys

						__A		:	Optional[Any]      =		_LazyModule(__name__, globals()['''__file__'''], _import_structure)



