
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


_lowerCamelCase :       List[Any]     					=    threading.Lock()
_lowerCamelCase :       str     					=    None

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

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

_lowerCamelCase :       Optional[Any]     					=    True






def  a_	( )				->						int:
			_snake_case						=    os.getenv('DIFFUSERS_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 DIFFUSERS_VERBOSITY={env_level_str}, '''
									    f'''has to be one of: { ', '.join(log_levels.keys()				) }'''				)
			return _default_log_level






def  a_	( )				->						Tuple:
			return __name__.split('.'				)[0]






def  a_	( )				->						Any:
			return logging.getLogger(_get_library_name()				)






def  a_	( )				->						Tuple:
			global _default_handler

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

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






def  a_	( )				->						Tuple:
			global _default_handler

			with _lock:
						if not _default_handler:
									return

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






def  a_	( )				->						Tuple:
			return log_levels






def  a_	( __lowercase     :			Optional[str] = None				)				->						Optional[Any]:







			if name is None:
						_snake_case						=    _get_library_name()

			_configure_library_root_logger()
			return logging.getLogger(_A				)






def  a_	( )				->						Optional[Any]:
			_configure_library_root_logger()
			return _get_library_root_logger().getEffectiveLevel()






def  a_	( __lowercase     :			int				)				->						Optional[int]:
			_configure_library_root_logger()
			_get_library_root_logger().setLevel(_A				)






def  a_	( )				->						Dict:
			return set_verbosity(_A				)






def  a_	( )				->						Any:
			return set_verbosity(_A				)






def  a_	( )				->						Any:
			return set_verbosity(_A				)






def  a_	( )				->						Optional[int]:
			return set_verbosity(_A				)






def  a_	( )				->						str:
			_configure_library_root_logger()

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






def  a_	( )				->						List[str]:
			_configure_library_root_logger()

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






def  a_	( __lowercase     :			logging.Handler				)				->						str:
			_configure_library_root_logger()

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






def  a_	( __lowercase     :			logging.Handler				)				->						int:
			_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  a_	( )				->						Tuple:
			_configure_library_root_logger()
			_snake_case						=    False






def  a_	( )				->						Any:
			_configure_library_root_logger()
			_snake_case						=    True






def  a_	( )				->						List[Any]:
			_snake_case						=    _get_library_root_logger().handlers

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






def  a_	( )				->						int:
			_snake_case						=    _get_library_root_logger().handlers

			for handler in handlers:
						handler.setFormatter(_A				)






def  a_	( self     :			List[Any] ,      *__lowercase     :			int ,      **__lowercase     :			Any				)				->						Union[str, Any]:
			_snake_case						=    os.getenv('DIFFUSERS_NO_ADVISORY_WARNINGS' ,      _A				)
			if no_advisory_warnings:
						return
			self.warning(*_A ,      **_A				)


_lowerCamelCase :       List[Any]     					=    warning_advice




class      SCREAMING_SNAKE_CASE__  :





	'''simple docstring'''



	def __init__(						self			:					Union[str, Any]    ,						*lowercase			:					List[str]    ,						**lowercase			:					Union[str, Any]			):  # pylint: disable=unused-argument


				'''simple docstring'''


				_snake_case						=    args[0] if args else None



	def __iter__(						self			:					int			):


				'''simple docstring'''


				return iter(self._iterator			)



	def __getattr__(						self			:					List[str]    ,						lowercase			:					Tuple			):


				'''simple docstring'''


				def empty_fn(*lowercase			:					str    ,						**lowercase			:					int			):  # pylint: disable=unused-argument
							return

				return empty_fn



	def __enter__(						self			:					str			):


				'''simple docstring'''


				return self





	def __exit__(						self			:					List[Any]    ,						lowercase			:					str    ,						lowercase			:					Union[str, Any]    ,						lowercase			:					Union[str, Any]			):


				'''simple docstring'''


				return




class      SCREAMING_SNAKE_CASE__  :





	'''simple docstring'''



	def __call__(						self			:					Any    ,						*lowercase			:					Any    ,						**lowercase			:					Optional[int]			):


				'''simple docstring'''


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



	def 				A							(						self			:					Optional[Any]    ,						*lowercase			:					str    ,						**lowercase			:					Dict			):


				'''simple docstring'''


				_snake_case						=    None
				if _tqdm_active:
							return tqdm_lib.tqdm.set_lock(*lowercase_    ,						**lowercase_			)





	def 				A							(						self			:					int			):


				'''simple docstring'''


				if _tqdm_active:
							return tqdm_lib.tqdm.get_lock()




_lowerCamelCase :       Union[str, Any]     					=    _tqdm_cls()






def  a_	( )				->						str:
			global _tqdm_active
			return bool(_tqdm_active				)






def  a_	( )				->						Any:
			global _tqdm_active
			_snake_case						=    True






def  a_	( )				->						Any:
			global _tqdm_active
			_snake_case						=    False


from typing import TYPE_CHECKING

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


_lowerCamelCase :       Optional[int]     					=    {}

try:
			if not is_sentencepiece_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_lowerCamelCase :       List[str]     					=    ['''MBart50Tokenizer''']

try:
			if not is_tokenizers_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_lowerCamelCase :       Optional[int]     					=    ['''MBart50TokenizerFast''']


if TYPE_CHECKING:
			try:
						if not is_sentencepiece_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .tokenization_mbartaa import MBartaaTokenizer

			try:
						if not is_tokenizers_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .tokenization_mbartaa_fast import MBartaaTokenizerFast

else:
			import sys

			_lowerCamelCase :       int     					=    _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)