




'''simple docstring'''


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


_snake_case : Union[str, Any]  				=						threading.Lock()
_snake_case : Optional[logging.Handler]  				=						None

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

_snake_case : int  				=						logging.WARNING

_snake_case : Tuple  				=						True
def 						snake_case_       ():





							'''simple docstring'''


							_a      	=							os.getenv('''TRANSFORMERS_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 TRANSFORMERS_VERBOSITY={env_level_str}, '
																					    f'has to be one of: { ", ".join(log_levels.keys() ) }' )
							return _default_log_level
def 						snake_case_       ():





							'''simple docstring'''


							return __name__.split('''.''' )[0]
def 						snake_case_       ():





							'''simple docstring'''


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





							'''simple docstring'''


							global _default_handler

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

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





							'''simple docstring'''


							global _default_handler

							with _lock:
														if not _default_handler:
																					return

														_a      	=							_get_library_root_logger()
														library_root_logger.removeHandler(_default_handler )
														library_root_logger.setLevel(logging.NOTSET )
														_a      	=							None
def 						snake_case_       ():





							'''simple docstring'''


							return log_levels
def 						snake_case_       (UpperCamelCase			:    Optional[str] = None ):





							'''simple docstring'''


							if name is None:
														_a      	=							_get_library_name()

							_configure_library_root_logger()
							return logging.getLogger(UpperCamelCase )
def 						snake_case_       ():





							'''simple docstring'''


							_configure_library_root_logger()
							return _get_library_root_logger().getEffectiveLevel()
def 						snake_case_       (UpperCamelCase			:    int ):





							'''simple docstring'''


							_configure_library_root_logger()
							_get_library_root_logger().setLevel(UpperCamelCase )
def 						snake_case_       ():





							'''simple docstring'''


							return set_verbosity(UpperCamelCase )
def 						snake_case_       ():





							'''simple docstring'''


							return set_verbosity(UpperCamelCase )
def 						snake_case_       ():





							'''simple docstring'''


							return set_verbosity(UpperCamelCase )
def 						snake_case_       ():





							'''simple docstring'''


							return set_verbosity(UpperCamelCase )
def 						snake_case_       ():





							'''simple docstring'''


							_configure_library_root_logger()

							assert _default_handler is not None
							_get_library_root_logger().removeHandler(_default_handler )
def 						snake_case_       ():





							'''simple docstring'''


							_configure_library_root_logger()

							assert _default_handler is not None
							_get_library_root_logger().addHandler(_default_handler )
def 						snake_case_       (UpperCamelCase			:    logging.Handler ):





							'''simple docstring'''


							_configure_library_root_logger()

							assert handler is not None
							_get_library_root_logger().addHandler(UpperCamelCase )
def 						snake_case_       (UpperCamelCase			:    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(UpperCamelCase )
def 						snake_case_       ():





							'''simple docstring'''


							_configure_library_root_logger()
							_a      	=							False
def 						snake_case_       ():





							'''simple docstring'''


							_configure_library_root_logger()
							_a      	=							True
def 						snake_case_       ():





							'''simple docstring'''


							_a      	=							_get_library_root_logger().handlers

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





							'''simple docstring'''


							_a      	=							_get_library_root_logger().handlers

							for handler in handlers:
														handler.setFormatter(UpperCamelCase )
def 						snake_case_       (self			:    List[str]					,		*UpperCamelCase			:    Optional[Any]					,		**UpperCamelCase			:    Optional[int] ):





							'''simple docstring'''


							_a      	=							os.getenv('''TRANSFORMERS_NO_ADVISORY_WARNINGS'''					,		UpperCamelCase )
							if no_advisory_warnings:
														return
							self.warning(*UpperCamelCase					,		**UpperCamelCase )


_snake_case : Any  				=						warning_advice
@functools.lru_cache(UpperCamelCase )
def 						snake_case_       (self			:    List[str]					,		*UpperCamelCase			:    List[Any]					,		**UpperCamelCase			:    Union[str, Any] ):





							'''simple docstring'''


							self.warning(*UpperCamelCase					,		**UpperCamelCase )


_snake_case : Optional[int]  				=						warning_once

class      A       :







							def __init__(    self			:    Optional[Any]				,     *lowerCAmelCase_			:    Dict				,     **lowerCAmelCase_			:    Optional[Any]   )     ->				int:  # pylint: disable=unused-argument


														"""simple docstring"""


														_a      	=							args[0] if args else None







							def __iter__(    self			:    str   )     ->				Any:


														"""simple docstring"""


														return iter(self._iterator   )







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


														"""simple docstring"""


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

														return empty_fn







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


														"""simple docstring"""


														return self







							def __exit__(    self			:    List[Any]				,     lowerCAmelCase_			:    List[Any]				,     lowerCAmelCase_			:    List[str]				,     lowerCAmelCase_			:    Any   )     ->				Tuple:


														"""simple docstring"""


														return



class      A       :







							def __call__(    self			:    Optional[Any]				,     *lowerCAmelCase_			:    Optional[int]				,     **lowerCAmelCase_			:    str   )     ->				List[Any]:


														"""simple docstring"""


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







							def   __lowerCAmelCase     (    self			:    str				,     *lowerCAmelCase_			:    List[Any]				,     **lowerCAmelCase_			:    Optional[Any]   )     ->				Any:


														"""simple docstring"""


														_a      	=							None
														if _tqdm_active:
																					return tqdm_lib.tqdm.set_lock(*lowerCAmelCase_				,     **lowerCAmelCase_   )







							def   __lowerCAmelCase     (    self			:    Dict   )     ->				str:


														"""simple docstring"""


														if _tqdm_active:
																					return tqdm_lib.tqdm.get_lock()



_snake_case : Any  				=						_tqdm_cls()
def 						snake_case_       ():





							'''simple docstring'''


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





							'''simple docstring'''


							global _tqdm_active
							_a      	=							True
							hf_hub_utils.enable_progress_bars()

def 						snake_case_       ():





							'''simple docstring'''


							global _tqdm_active
							_a      	=							False
							hf_hub_utils.disable_progress_bars()







'''simple docstring'''


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
    is_vision_available,
)


_snake_case : str  				=						{
    'configuration_layoutlmv3': [
        'LAYOUTLMV3_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'LayoutLMv3Config',
        'LayoutLMv3OnnxConfig',
    ],
    'processing_layoutlmv3': ['LayoutLMv3Processor'],
    'tokenization_layoutlmv3': ['LayoutLMv3Tokenizer'],
}

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

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_snake_case : Optional[int]  				=						[
				    'LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'LayoutLMv3ForQuestionAnswering',
				    'LayoutLMv3ForSequenceClassification',
				    'LayoutLMv3ForTokenClassification',
				    'LayoutLMv3Model',
				    'LayoutLMv3PreTrainedModel',
				]

try:
				if not is_tf_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_snake_case : Tuple  				=						[
				    'TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST',
				    'TFLayoutLMv3ForQuestionAnswering',
				    'TFLayoutLMv3ForSequenceClassification',
				    'TFLayoutLMv3ForTokenClassification',
				    'TFLayoutLMv3Model',
				    'TFLayoutLMv3PreTrainedModel',
				]

try:
				if not is_vision_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				_snake_case : List[Any]  				=						['LayoutLMv3FeatureExtractor']
				_snake_case : Tuple  				=						['LayoutLMv3ImageProcessor']


if TYPE_CHECKING:
				from .configuration_layoutlmva import (
				    LAYOUTLMV3_PRETRAINED_CONFIG_ARCHIVE_MAP,
				    LayoutLMvaConfig,
				    LayoutLMvaOnnxConfig,
				)
				from .processing_layoutlmva import LayoutLMvaProcessor
				from .tokenization_layoutlmva import LayoutLMvaTokenizer

				try:
								if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_layoutlmva_fast import LayoutLMvaTokenizerFast

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_layoutlmva import (
								    LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST,
								    LayoutLMvaForQuestionAnswering,
								    LayoutLMvaForSequenceClassification,
								    LayoutLMvaForTokenClassification,
								    LayoutLMvaModel,
								    LayoutLMvaPreTrainedModel,
								)

				try:
								if not is_tf_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_tf_layoutlmva import (
								    TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST,
								    TFLayoutLMvaForQuestionAnswering,
								    TFLayoutLMvaForSequenceClassification,
								    TFLayoutLMvaForTokenClassification,
								    TFLayoutLMvaModel,
								    TFLayoutLMvaPreTrainedModel,
								)

				try:
								if not is_vision_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .feature_extraction_layoutlmva import LayoutLMvaFeatureExtractor
								from .image_processing_layoutlmva import LayoutLMvaImageProcessor

else:
				import sys

				_snake_case : Any  				=						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

