






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


lowerCamelCase_				: Optional[int]    	=							logging.get_logger(__name__)
class    _SCREAMING_SNAKE_CASE							:
			__a							:							Union[str, Any]					     =					42
			__a							:							Optional[Any]					     =					None






			@staticmethod
			def 				A      (   )							->    Union[str, Any]:

									'''simple docstring'''







									raise NotImplementedError






			def 				A      (   self							:						Tuple ,      lowercase							:						Optional[int] ,      lowercase							:						int ,      lowercase							:						str ,      **lowercase							:						str			)							->    List[Any]:

									'''simple docstring'''







									raise NotImplementedError






			def 				A      (   self							:						int ,      lowercase							:						Dict			)							->    Union[str, Any]:

									'''simple docstring'''







									raise NotImplementedError






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

									'''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							:						Any			)							->    List[str]:

									'''simple docstring'''







									return f"`pip install {cls.pip_package or cls.name}`"
class    _SCREAMING_SNAKE_CASE							(		lowercase_	):
			__a							:							str					     =					"optuna"






			@staticmethod
			def 				A      (   )							->    List[str]:

									'''simple docstring'''







									return is_optuna_available()






			def 				A      (   self							:						Any ,      lowercase							:						Union[str, Any] ,      lowercase							:						int ,      lowercase							:						str ,      **lowercase							:						Dict			)							->    Any:

									'''simple docstring'''







									return run_hp_search_optuna(lowerCamelCase_ ,      lowerCamelCase_ ,      lowerCamelCase_ ,      **lowerCamelCase_			)







			def 				A      (   self							:						str ,      lowercase							:						Any			)							->    List[str]:

									'''simple docstring'''







									return default_hp_space_optuna(lowerCamelCase_			)
class    _SCREAMING_SNAKE_CASE							(		lowercase_	):
			__a							:							Union[str, Any]					     =					"ray"
			__a							:							List[Any]					     =					"\'ray[tune]\'"






			@staticmethod
			def 				A      (   )							->    str:

									'''simple docstring'''







									return is_ray_available()






			def 				A      (   self							:						Any ,      lowercase							:						Any ,      lowercase							:						int ,      lowercase							:						str ,      **lowercase							:						int			)							->    Optional[int]:

									'''simple docstring'''







									return run_hp_search_ray(lowerCamelCase_ ,      lowerCamelCase_ ,      lowerCamelCase_ ,      **lowerCamelCase_			)







			def 				A      (   self							:						List[str] ,      lowercase							:						Optional[int]			)							->    Optional[Any]:

									'''simple docstring'''







									return default_hp_space_ray(lowerCamelCase_			)
class    _SCREAMING_SNAKE_CASE							(		lowercase_	):
			__a							:							List[str]					     =					"sigopt"






			@staticmethod
			def 				A      (   )							->    Dict:

									'''simple docstring'''







									return is_sigopt_available()






			def 				A      (   self							:						Optional[Any] ,      lowercase							:						Any ,      lowercase							:						int ,      lowercase							:						str ,      **lowercase							:						int			)							->    str:

									'''simple docstring'''







									return run_hp_search_sigopt(lowerCamelCase_ ,      lowerCamelCase_ ,      lowerCamelCase_ ,      **lowerCamelCase_			)







			def 				A      (   self							:						List[Any] ,      lowercase							:						Optional[Any]			)							->    Optional[Any]:

									'''simple docstring'''







									return default_hp_space_sigopt(lowerCamelCase_			)
class    _SCREAMING_SNAKE_CASE							(		lowercase_	):
			__a							:							Optional[int]					     =					"wandb"






			@staticmethod
			def 				A      (   )							->    Any:

									'''simple docstring'''







									return is_wandb_available()






			def 				A      (   self							:						Union[str, Any] ,      lowercase							:						str ,      lowercase							:						int ,      lowercase							:						str ,      **lowercase							:						Optional[Any]			)							->    List[str]:

									'''simple docstring'''







									return run_hp_search_wandb(lowerCamelCase_ ,      lowerCamelCase_ ,      lowerCamelCase_ ,      **lowerCamelCase_			)







			def 				A      (   self							:						Union[str, Any] ,      lowercase							:						Tuple			)							->    Any:

									'''simple docstring'''







									return default_hp_space_wandb(lowerCamelCase_			)
lowerCamelCase_				: List[Any]    	=							{
    HPSearchBackend(backend.name): backend for backend in [OptunaBackend, RayTuneBackend, SigOptBackend, WandbBackend]
}







def 	__magic_name__( ):
						'''simple docstring'''





						UpperCamelCase__         = [backend for backend in ALL_HYPERPARAMETER_SEARCH_BACKENDS.values() if backend.is_available()]
						if len(lowerCamelCase_					) > 0:
												UpperCamelCase__         = available_backends[0].name
												if len(lowerCamelCase_					) > 1:
																		logger.info(
																		    f"{len(lowerCamelCase_					)} 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,
)


lowerCamelCase_				: Tuple    	=							{
    '''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:
					lowerCamelCase_				: Tuple    	=							['''LayoutLMv3TokenizerFast''']

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCamelCase_				: Union[str, Any]    	=							[
					    '''LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''LayoutLMv3ForQuestionAnswering''',
					    '''LayoutLMv3ForSequenceClassification''',
					    '''LayoutLMv3ForTokenClassification''',
					    '''LayoutLMv3Model''',
					    '''LayoutLMv3PreTrainedModel''',
					]

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

try:
					if not is_vision_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCamelCase_				: Optional[Any]    	=							['''LayoutLMv3FeatureExtractor''']
					lowerCamelCase_				: Dict    	=							['''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

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