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


_UpperCAmelCase            =		threading.Lock()
_UpperCAmelCase            =		None

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

_UpperCAmelCase            =		logging.WARNING

_UpperCAmelCase            =		True




def     UpperCamelCase						(	):
		'''simple docstring'''




		A_		:    Tuple         =				os.getenv('TRANSFORMERS_VERBOSITY'						,__lowercase     )
		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     UpperCamelCase						(	):
		'''simple docstring'''




		return __name__.split('.'     )[0]




def     UpperCamelCase						(	):
		'''simple docstring'''




		return logging.getLogger(_get_library_name()     )




def     UpperCamelCase						(	):
		'''simple docstring'''




		global _default_handler

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

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




def     UpperCamelCase						(	):
		'''simple docstring'''




		global _default_handler

		with _lock:
				if not _default_handler:
						return

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




def     UpperCamelCase						(	):
		'''simple docstring'''




		return log_levels




def     UpperCamelCase						(	__lowercase						:			Optional[str] = None     ):
		'''simple docstring'''




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

		_configure_library_root_logger()
		return logging.getLogger(__lowercase     )




def     UpperCamelCase						(	):
		'''simple docstring'''




		_configure_library_root_logger()
		return _get_library_root_logger().getEffectiveLevel()




def     UpperCamelCase						(	__lowercase						:			int     ):
		'''simple docstring'''




		_configure_library_root_logger()
		_get_library_root_logger().setLevel(__lowercase     )




def     UpperCamelCase						(	):
		'''simple docstring'''




		return set_verbosity(__lowercase     )




def     UpperCamelCase						(	):
		'''simple docstring'''




		return set_verbosity(__lowercase     )




def     UpperCamelCase						(	):
		'''simple docstring'''




		return set_verbosity(__lowercase     )




def     UpperCamelCase						(	):
		'''simple docstring'''




		return set_verbosity(__lowercase     )




def     UpperCamelCase						(	):
		'''simple docstring'''




		_configure_library_root_logger()

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




def     UpperCamelCase						(	):
		'''simple docstring'''




		_configure_library_root_logger()

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




def     UpperCamelCase						(	__lowercase						:			logging.Handler     ):
		'''simple docstring'''




		_configure_library_root_logger()

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




def     UpperCamelCase						(	__lowercase						:			logging.Handler     ):
		'''simple docstring'''




		_configure_library_root_logger()

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




def     UpperCamelCase						(	):
		'''simple docstring'''




		_configure_library_root_logger()
		A_		:    Any         =				False




def     UpperCamelCase						(	):
		'''simple docstring'''




		_configure_library_root_logger()
		A_		:    Dict         =				True




def     UpperCamelCase						(	):
		'''simple docstring'''




		A_		:    List[str]         =				_get_library_root_logger().handlers

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




def     UpperCamelCase						(	):
		'''simple docstring'''




		A_		:    Any         =				_get_library_root_logger().handlers

		for handler in handlers:
				handler.setFormatter(__lowercase     )




def     UpperCamelCase						(	self						:			Optional[int]						,*__lowercase						:			Optional[Any]						,**__lowercase						:			List[Any]     ):
		'''simple docstring'''




		A_		:    Optional[Any]         =				os.getenv('TRANSFORMERS_NO_ADVISORY_WARNINGS'						,__lowercase     )
		if no_advisory_warnings:
				return
		self.warning(*__lowercase						,**__lowercase     )


_UpperCAmelCase            =		warning_advice




@functools.lru_cache(__lowercase     )
def     UpperCamelCase						(	self						:			List[Any]						,*__lowercase						:			List[str]						,**__lowercase						:			str     ):
		'''simple docstring'''




		self.warning(*__lowercase						,**__lowercase     )


_UpperCAmelCase            =		warning_once





class UpperCAmelCase						:


				'''simple docstring'''






				def __init__(						self		,     *lowercase		,     **lowercase ):  # pylint: disable=unused-argument



						"""simple docstring"""





						A_		:    Dict         =				args[0] if args else None
				def __iter__(						self ):



						"""simple docstring"""





						return iter(self._iterator )
				def __getattr__(						self		,     lowercase ):



						"""simple docstring"""





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

						return empty_fn
				def __enter__(						self ):



						"""simple docstring"""





						return self







				def __exit__(						self		,     lowercase		,     lowercase		,     lowercase ):



						"""simple docstring"""





						return





class UpperCAmelCase						:


				'''simple docstring'''






				def __call__(						self		,     *lowercase		,     **lowercase ):



						"""simple docstring"""





						if _tqdm_active:
								return tqdm_lib.tqdm(*lowercase		,     **lowercase )
						else:
								return EmptyTqdm(*lowercase		,     **lowercase )
				def   lowerCAmelCase_       (						self		,     *lowercase		,     **lowercase ):



						"""simple docstring"""





						A_		:    Optional[int]         =				None
						if _tqdm_active:
								return tqdm_lib.tqdm.set_lock(*lowercase		,     **lowercase )







				def   lowerCAmelCase_       (						self ):



						"""simple docstring"""





						if _tqdm_active:
								return tqdm_lib.tqdm.get_lock()

_UpperCAmelCase            =		_tqdm_cls()




def     UpperCamelCase						(	):
		'''simple docstring'''




		global _tqdm_active
		return bool(_tqdm_active     )




def     UpperCamelCase						(	):
		'''simple docstring'''




		global _tqdm_active
		A_		:    Optional[Any]         =				True
		hf_hub_utils.enable_progress_bars()




def     UpperCamelCase						(	):
		'''simple docstring'''




		global _tqdm_active
		A_		:    Dict         =				False
		hf_hub_utils.disable_progress_bars()







from typing import TYPE_CHECKING

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


_UpperCAmelCase            =		{
    """configuration_bridgetower""": [
        """BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """BridgeTowerConfig""",
        """BridgeTowerTextConfig""",
        """BridgeTowerVisionConfig""",
    ],
    """processing_bridgetower""": ["""BridgeTowerProcessor"""],
}

try:
	if not is_vision_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_UpperCAmelCase            =		["""BridgeTowerImageProcessor"""]

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_UpperCAmelCase            =		[
	    """BRIDGETOWER_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """BridgeTowerForContrastiveLearning""",
	    """BridgeTowerForImageAndTextRetrieval""",
	    """BridgeTowerForMaskedLM""",
	    """BridgeTowerModel""",
	    """BridgeTowerPreTrainedModel""",
	]


if TYPE_CHECKING:
	from .configuration_bridgetower import (
	    BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP,
	    BridgeTowerConfig,
	    BridgeTowerTextConfig,
	    BridgeTowerVisionConfig,
	)
	from .processing_bridgetower import BridgeTowerProcessor

	try:
		if not is_vision_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .image_processing_bridgetower import BridgeTowerImageProcessor

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_bridgetower import (
		    BRIDGETOWER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    BridgeTowerForContrastiveLearning,
		    BridgeTowerForImageAndTextRetrieval,
		    BridgeTowerForMaskedLM,
		    BridgeTowerModel,
		    BridgeTowerPreTrainedModel,
		)


else:
	import sys

	_UpperCAmelCase            =		_LazyModule(__name__, globals()["""__file__"""], _import_structure)






