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


SCREAMING_SNAKE_CASE_					     =	logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_					     =	{
    '''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       lowerCAmelCase_		(				A__ ):



							'''simple docstring'''





							_snake_case						      =		'''owlvit_text_model'''




							def __init__( self    ,				snake_case_=49_408    ,				snake_case_=512    ,				snake_case_=2_048    ,				snake_case_=12    ,				snake_case_=8    ,				snake_case_=16    ,				snake_case_="quick_gelu"    ,				snake_case_=1e-5    ,				snake_case_=0.0    ,				snake_case_=0.02    ,				snake_case_=1.0    ,				snake_case_=0    ,				snake_case_=49_406    ,				snake_case_=49_407    ,				**snake_case_    ,				)       ->  int:
													super().__init__(pad_token_id=snake_case_    ,				bos_token_id=snake_case_    ,				eos_token_id=snake_case_    ,				**snake_case_				)

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




							@classmethod
							def    A__						( cls    ,				snake_case_    ,				**snake_case_				)       ->  "PretrainedConfig":
													cls._set_token_in_kwargs(snake_case_				)

													__lowerCAmelCase   ,     __lowerCAmelCase     =  cls.get_config_dict(snake_case_    ,				**snake_case_				)

													# get the text config dict if we are loading from OwlViTConfig
													if config_dict.get("""model_type"""				) == "owlvit":
																			__lowerCAmelCase     =  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(snake_case_    ,				**snake_case_				)
class       lowerCAmelCase_		(				A__ ):



							'''simple docstring'''





							_snake_case						      =		'''owlvit_vision_model'''




							def __init__( self    ,				snake_case_=768    ,				snake_case_=3_072    ,				snake_case_=12    ,				snake_case_=12    ,				snake_case_=3    ,				snake_case_=768    ,				snake_case_=32    ,				snake_case_="quick_gelu"    ,				snake_case_=1e-5    ,				snake_case_=0.0    ,				snake_case_=0.02    ,				snake_case_=1.0    ,				**snake_case_    ,				)       ->  List[Any]:
													super().__init__(**snake_case_				)

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




							@classmethod
							def    A__						( cls    ,				snake_case_    ,				**snake_case_				)       ->  "PretrainedConfig":
													cls._set_token_in_kwargs(snake_case_				)

													__lowerCAmelCase   ,     __lowerCAmelCase     =  cls.get_config_dict(snake_case_    ,				**snake_case_				)

													# get the vision config dict if we are loading from OwlViTConfig
													if config_dict.get("""model_type"""				) == "owlvit":
																			__lowerCAmelCase     =  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(snake_case_    ,				**snake_case_				)
class       lowerCAmelCase_		(				A__ ):



							'''simple docstring'''





							_snake_case						      =		'''owlvit'''
							_snake_case						      =		True




							def __init__( self    ,				snake_case_=None    ,				snake_case_=None    ,				snake_case_=512    ,				snake_case_=2.6_592    ,				snake_case_=True    ,				**snake_case_    ,				)       ->  Dict:
													super().__init__(**snake_case_				)

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

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

													__lowerCAmelCase     =  OwlViTTextConfig(**snake_case_				)
													__lowerCAmelCase     =  OwlViTVisionConfig(**snake_case_				)

													__lowerCAmelCase     =  projection_dim
													__lowerCAmelCase     =  logit_scale_init_value
													__lowerCAmelCase     =  return_dict
													__lowerCAmelCase     =  1.0




							@classmethod
							def    A__						( cls    ,				snake_case_    ,				**snake_case_				)       ->  "PretrainedConfig":
													cls._set_token_in_kwargs(snake_case_				)

													__lowerCAmelCase   ,     __lowerCAmelCase     =  cls.get_config_dict(snake_case_    ,				**snake_case_				)

													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(snake_case_    ,				**snake_case_				)




							@classmethod
							def    A__						( cls    ,				snake_case_    ,				snake_case_    ,				**snake_case_				)       ->  Union[str, Any]:
													__lowerCAmelCase     =  {}
													__lowerCAmelCase     =  text_config
													__lowerCAmelCase     =  vision_config

													return cls.from_dict(snake_case_    ,				**snake_case_				)




							def    A__						( self				)       ->  Tuple:
													__lowerCAmelCase     =  copy.deepcopy(self.__dict__				)
													__lowerCAmelCase     =  self.text_config.to_dict()
													__lowerCAmelCase     =  self.vision_config.to_dict()
													__lowerCAmelCase     =  self.__class__.model_type
													return output
class       lowerCAmelCase_		(				A__ ):



							'''simple docstring'''





							@property
							def    A__						( self				)       ->  Mapping[str, Mapping[int, str]]:
													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				)       ->  Mapping[str, Mapping[int, str]]:
													return OrderedDict(
													    [
													        ("""logits_per_image""", {0: """batch"""}),
													        ("""logits_per_text""", {0: """batch"""}),
													        ("""text_embeds""", {0: """batch"""}),
													        ("""image_embeds""", {0: """batch"""}),
													    ]				)




							@property
							def    A__						( self				)       ->  float:
													return 1e-4




							def    A__						( self    ,				snake_case_    ,				snake_case_ = -1    ,				snake_case_ = -1    ,				snake_case_ = None    ,				)       ->  Mapping[str, Any]:
													__lowerCAmelCase     =  super().generate_dummy_inputs(
													    processor.tokenizer    ,				batch_size=snake_case_    ,				seq_length=snake_case_    ,				framework=snake_case_				)
													__lowerCAmelCase     =  super().generate_dummy_inputs(
													    processor.image_processor    ,				batch_size=snake_case_    ,				framework=snake_case_				)
													return {**text_input_dict, **image_input_dict}




							@property
							def    A__						( self				)       ->  int:
													return 14


"""simple docstring"""
import warnings

from ..trainer import Trainer
from ..utils import logging


SCREAMING_SNAKE_CASE_					     =	logging.get_logger(__name__)
class       lowerCAmelCase_		(				A__ ):



							'''simple docstring'''





							def __init__( self    ,				snake_case_=None    ,				**snake_case_				)       ->  Optional[Any]:
													warnings.warn(
													    """`SageMakerTrainer` is deprecated and will be removed in v5 of Transformers. You can use `Trainer` """
													    """instead."""    ,				snake_case_    ,				)
													super().__init__(args=snake_case_    ,				**snake_case_				)
