





"""simple docstring"""


from .integrations import (
    is_optuna_available,
    is_ray_available,
    is_sigopt_available,
    is_wandb_available,
    run_hp_search_optuna,
    run_hp_search_ray,
    run_hp_search_sigopt,
    run_hp_search_wandb,
)
from .trainer_utils import (
    HPSearchBackend,
    default_hp_space_optuna,
    default_hp_space_ray,
    default_hp_space_sigopt,
    default_hp_space_wandb,
)
from .utils import logging


__magic_name__       :					int						=			logging.get_logger(__name__)






class 							lowercase__			:

			"""simple docstring"""
			__lowerCAmelCase     :				str
			__lowerCAmelCase     :				str										=  None







			@staticmethod
			def   _a      (      ):






									'''simple docstring'''







									raise NotImplementedError







			def   _a      (      self						,   _A						,   _A						,   _A						,   **_A    ):






									'''simple docstring'''







									raise NotImplementedError







			def   _a      (      self						,   _A    ):






									'''simple docstring'''







									raise NotImplementedError







			def   _a      (      self    ):






									'''simple docstring'''







									if not self.is_available():
															raise RuntimeError(
															    f"""You picked the {self.name} backend, but it is not installed. Run {self.pip_install()}."""    )







			@classmethod
			def   _a      (      cls    ):






									'''simple docstring'''







									return f"""`pip install {cls.pip_package or cls.name}`"""






class 							lowercase__			(   __SCREAMING_SNAKE_CASE	):

			"""simple docstring"""
			__lowerCAmelCase     :				Optional[Any]										=  """optuna"""







			@staticmethod
			def   _a      (      ):






									'''simple docstring'''







									return is_optuna_available()







			def   _a      (      self						,   _A						,   _A						,   _A						,   **_A    ):






									'''simple docstring'''







									return run_hp_search_optuna(_A						,   _A						,   _A						,   **_A    )







			def   _a      (      self						,   _A    ):






									'''simple docstring'''







									return default_hp_space_optuna(_A    )






class 							lowercase__			(   __SCREAMING_SNAKE_CASE	):

			"""simple docstring"""
			__lowerCAmelCase     :				Any										=  """ray"""
			__lowerCAmelCase     :				Optional[int]										=  """'ray[tune]'"""







			@staticmethod
			def   _a      (      ):






									'''simple docstring'''







									return is_ray_available()







			def   _a      (      self						,   _A						,   _A						,   _A						,   **_A    ):






									'''simple docstring'''







									return run_hp_search_ray(_A						,   _A						,   _A						,   **_A    )







			def   _a      (      self						,   _A    ):






									'''simple docstring'''







									return default_hp_space_ray(_A    )






class 							lowercase__			(   __SCREAMING_SNAKE_CASE	):

			"""simple docstring"""
			__lowerCAmelCase     :				Tuple										=  """sigopt"""







			@staticmethod
			def   _a      (      ):






									'''simple docstring'''







									return is_sigopt_available()







			def   _a      (      self						,   _A						,   _A						,   _A						,   **_A    ):






									'''simple docstring'''







									return run_hp_search_sigopt(_A						,   _A						,   _A						,   **_A    )







			def   _a      (      self						,   _A    ):






									'''simple docstring'''







									return default_hp_space_sigopt(_A    )






class 							lowercase__			(   __SCREAMING_SNAKE_CASE	):

			"""simple docstring"""
			__lowerCAmelCase     :				Optional[Any]										=  """wandb"""







			@staticmethod
			def   _a      (      ):






									'''simple docstring'''







									return is_wandb_available()







			def   _a      (      self						,   _A						,   _A						,   _A						,   **_A    ):






									'''simple docstring'''







									return run_hp_search_wandb(_A						,   _A						,   _A						,   **_A    )







			def   _a      (      self						,   _A    ):






									'''simple docstring'''







									return default_hp_space_wandb(_A    )


__magic_name__       :					Dict						=			{
    HPSearchBackend(backend.name): backend for backend in [OptunaBackend, RayTuneBackend, SigOptBackend, WandbBackend]
}

def      UpperCamelCase							():
						UpperCamelCase				:		str				   =			[backend for backend in ALL_HYPERPARAMETER_SEARCH_BACKENDS.values() if backend.is_available()]
						if len(SCREAMING_SNAKE_CASE     ) > 0:
												UpperCamelCase				:		Dict				   =			available_backends[0].name
												if len(SCREAMING_SNAKE_CASE     ) > 1:
																		logger.info(
																		    f"""{len(SCREAMING_SNAKE_CASE     )} hyperparameter search backends available. Using {name} as the default."""     )
												return name
						raise RuntimeError(
						    """No hyperparameter search backend available.\n"""
						    + """\n""".join(
						        f""" - To install {backend.name} run {backend.pip_install()}"""
						        for backend in ALL_HYPERPARAMETER_SEARCH_BACKENDS.values()     )     )










"""simple docstring"""


from typing import TYPE_CHECKING

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


__magic_name__       :					Dict						=			{
    """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:
		__magic_name__       :					Optional[Any]						=			["""LayoutLMv3TokenizerFast"""]

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

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

try:
		if not is_vision_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__magic_name__       :					Union[str, Any]						=			["""LayoutLMv3FeatureExtractor"""]
		__magic_name__       :					Any						=			["""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

		__magic_name__       :					Union[str, Any]						=			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



