






'''simple docstring'''


import copy
import os
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union


if TYPE_CHECKING:
					from ...processing_utils import ProcessorMixin
					from ...utils import TensorType

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowerCamelCase_				: List[str]    	=							logging.get_logger(__name__)

lowerCamelCase_				: int    	=							{
    '''google/owlvit-base-patch32''': '''https://huggingface.co/google/owlvit-base-patch32/resolve/main/config.json''',
    '''google/owlvit-base-patch16''': '''https://huggingface.co/google/owlvit-base-patch16/resolve/main/config.json''',
    '''google/owlvit-large-patch14''': '''https://huggingface.co/google/owlvit-large-patch14/resolve/main/config.json''',
}
class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





			__a							:							int					     =					"owlvit_text_model"






			def __init__(   self							:						Tuple ,      lowercase							:						List[Any]=4_9_4_0_8 ,      lowercase							:						str=5_1_2 ,      lowercase							:						Union[str, Any]=2_0_4_8 ,      lowercase							:						int=1_2 ,      lowercase							:						List[str]=8 ,      lowercase							:						Optional[int]=1_6 ,      lowercase							:						Any="quick_gelu" ,      lowercase							:						List[Any]=1e-5 ,      lowercase							:						str=0.0 ,      lowercase							:						str=0.0_2 ,      lowercase							:						List[str]=1.0 ,      lowercase							:						Union[str, Any]=0 ,      lowercase							:						int=4_9_4_0_6 ,      lowercase							:						Optional[int]=4_9_4_0_7 ,      **lowercase							:						List[str] ,      )							->    Dict:

									'''simple docstring'''







									super().__init__(pad_token_id=lowercase ,      bos_token_id=lowercase ,      eos_token_id=lowercase ,      **lowercase			)

									UpperCamelCase__         = vocab_size
									UpperCamelCase__         = hidden_size
									UpperCamelCase__         = intermediate_size
									UpperCamelCase__         = num_hidden_layers
									UpperCamelCase__         = num_attention_heads
									UpperCamelCase__         = max_position_embeddings
									UpperCamelCase__         = hidden_act
									UpperCamelCase__         = layer_norm_eps
									UpperCamelCase__         = attention_dropout
									UpperCamelCase__         = initializer_range
									UpperCamelCase__         = initializer_factor







			@classmethod
			def 				A      (   cls							:						int ,      lowercase							:						Union[str, os.PathLike] ,      **lowercase							:						List[Any]			)							->    "PretrainedConfig":

									'''simple docstring'''







									cls._set_token_in_kwargs(lowercase			)

									UpperCamelCase__    ,   UpperCamelCase__         = cls.get_config_dict(lowercase ,      **lowercase			)

									# get the text config dict if we are loading from OwlViTConfig
									if config_dict.get("""model_type"""			) == "owlvit":
															UpperCamelCase__         = config_dict["""text_config"""]

									if "model_type" in config_dict and hasattr(cls ,      """model_type"""			) and config_dict["model_type"] != cls.model_type:
															logger.warning(
															    f"You are using a model of type {config_dict['model_type']} to instantiate a model of type "
															    f"{cls.model_type}. This is not supported for all configurations of models and can yield errors."			)

									return cls.from_dict(lowercase ,      **lowercase			)
class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





			__a							:							int					     =					"owlvit_vision_model"






			def __init__(   self							:						str ,      lowercase							:						Any=7_6_8 ,      lowercase							:						Union[str, Any]=3_0_7_2 ,      lowercase							:						Optional[Any]=1_2 ,      lowercase							:						str=1_2 ,      lowercase							:						Any=3 ,      lowercase							:						str=7_6_8 ,      lowercase							:						Optional[int]=3_2 ,      lowercase							:						str="quick_gelu" ,      lowercase							:						int=1e-5 ,      lowercase							:						List[Any]=0.0 ,      lowercase							:						Union[str, Any]=0.0_2 ,      lowercase							:						List[Any]=1.0 ,      **lowercase							:						Union[str, Any] ,      )							->    Union[str, Any]:

									'''simple docstring'''







									super().__init__(**lowercase			)

									UpperCamelCase__         = hidden_size
									UpperCamelCase__         = intermediate_size
									UpperCamelCase__         = num_hidden_layers
									UpperCamelCase__         = num_attention_heads
									UpperCamelCase__         = num_channels
									UpperCamelCase__         = image_size
									UpperCamelCase__         = patch_size
									UpperCamelCase__         = hidden_act
									UpperCamelCase__         = layer_norm_eps
									UpperCamelCase__         = attention_dropout
									UpperCamelCase__         = initializer_range
									UpperCamelCase__         = initializer_factor







			@classmethod
			def 				A      (   cls							:						str ,      lowercase							:						Union[str, os.PathLike] ,      **lowercase							:						Tuple			)							->    "PretrainedConfig":

									'''simple docstring'''







									cls._set_token_in_kwargs(lowercase			)

									UpperCamelCase__    ,   UpperCamelCase__         = cls.get_config_dict(lowercase ,      **lowercase			)

									# get the vision config dict if we are loading from OwlViTConfig
									if config_dict.get("""model_type"""			) == "owlvit":
															UpperCamelCase__         = config_dict["""vision_config"""]

									if "model_type" in config_dict and hasattr(cls ,      """model_type"""			) and config_dict["model_type"] != cls.model_type:
															logger.warning(
															    f"You are using a model of type {config_dict['model_type']} to instantiate a model of type "
															    f"{cls.model_type}. This is not supported for all configurations of models and can yield errors."			)

									return cls.from_dict(lowercase ,      **lowercase			)
class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





			__a							:							Optional[int]					     =					"owlvit"
			__a							:							Optional[Any]					     =					True






			def __init__(   self							:						Optional[Any] ,      lowercase							:						Tuple=None ,      lowercase							:						Any=None ,      lowercase							:						Union[str, Any]=5_1_2 ,      lowercase							:						Optional[int]=2.6_5_9_2 ,      lowercase							:						List[str]=True ,      **lowercase							:						Tuple ,      )							->    str:

									'''simple docstring'''







									super().__init__(**lowercase			)

									if text_config is None:
															UpperCamelCase__         = {}
															logger.info("""text_config is None. Initializing the OwlViTTextConfig with default values."""			)

									if vision_config is None:
															UpperCamelCase__         = {}
															logger.info("""vision_config is None. initializing the OwlViTVisionConfig with default values."""			)

									UpperCamelCase__         = OwlViTTextConfig(**lowercase			)
									UpperCamelCase__         = OwlViTVisionConfig(**lowercase			)

									UpperCamelCase__         = projection_dim
									UpperCamelCase__         = logit_scale_init_value
									UpperCamelCase__         = return_dict
									UpperCamelCase__         = 1.0






			@classmethod
			def 				A      (   cls							:						Optional[int] ,      lowercase							:						Union[str, os.PathLike] ,      **lowercase							:						List[Any]			)							->    "PretrainedConfig":

									'''simple docstring'''







									cls._set_token_in_kwargs(lowercase			)

									UpperCamelCase__    ,   UpperCamelCase__         = cls.get_config_dict(lowercase ,      **lowercase			)

									if "model_type" in config_dict and hasattr(cls ,      """model_type"""			) and config_dict["model_type"] != cls.model_type:
															logger.warning(
															    f"You are using a model of type {config_dict['model_type']} to instantiate a model of type "
															    f"{cls.model_type}. This is not supported for all configurations of models and can yield errors."			)

									return cls.from_dict(lowercase ,      **lowercase			)






			@classmethod
			def 				A      (   cls							:						Optional[int] ,      lowercase							:						Dict ,      lowercase							:						Dict ,      **lowercase							:						Tuple			)							->    List[Any]:

									'''simple docstring'''







									UpperCamelCase__         = {}
									UpperCamelCase__         = text_config
									UpperCamelCase__         = vision_config

									return cls.from_dict(lowercase ,      **lowercase			)







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

									'''simple docstring'''







									UpperCamelCase__         = copy.deepcopy(self.__dict__			)
									UpperCamelCase__         = self.text_config.to_dict()
									UpperCamelCase__         = self.vision_config.to_dict()
									UpperCamelCase__         = self.__class__.model_type
									return output
class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





			@property
			def 				A      (   self							:						List[Any]			)							->    Mapping[str, Mapping[int, str]]:

									'''simple docstring'''







									return OrderedDict(
									    [
									        ("""input_ids""", {0: """batch""", 1: """sequence"""}),
									        ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
									        ("""attention_mask""", {0: """batch""", 1: """sequence"""}),
									    ]			)






			@property
			def 				A      (   self							:						int			)							->    Mapping[str, Mapping[int, str]]:

									'''simple docstring'''







									return OrderedDict(
									    [
									        ("""logits_per_image""", {0: """batch"""}),
									        ("""logits_per_text""", {0: """batch"""}),
									        ("""text_embeds""", {0: """batch"""}),
									        ("""image_embeds""", {0: """batch"""}),
									    ]			)






			@property
			def 				A      (   self							:						int			)							->    float:

									'''simple docstring'''







									return 1e-4






			def 				A      (   self							:						List[Any] ,      lowercase							:						"ProcessorMixin" ,      lowercase							:						int = -1 ,      lowercase							:						int = -1 ,      lowercase							:						Optional["TensorType"] = None ,      )							->    Mapping[str, Any]:

									'''simple docstring'''







									UpperCamelCase__         = super().generate_dummy_inputs(
									    processor.tokenizer ,      batch_size=lowercase ,      seq_length=lowercase ,      framework=lowercase			)
									UpperCamelCase__         = super().generate_dummy_inputs(
									    processor.image_processor ,      batch_size=lowercase ,      framework=lowercase			)
									return {**text_input_dict, **image_input_dict}







			@property
			def 				A      (   self							:						int			)							->    int:

									'''simple docstring'''







									return 1_4








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