


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


UpperCamelCase						:				Dict             =      logging.get_logger(__name__)

UpperCamelCase						:				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 			lowerCamelCase__						(   UpperCAmelCase_			):
						lowerCAmelCase       =     """owlvit_text_model"""







						def __init__(							self   :    Tuple			,			_lowercase   :    Dict=49_408			,			_lowercase   :    List[str]=512			,			_lowercase   :    str=2_048			,			_lowercase   :    Optional[int]=12			,			_lowercase   :    Any=8			,			_lowercase   :    Optional[Any]=16			,			_lowercase   :    List[str]="quick_gelu"			,			_lowercase   :    Optional[int]=1e-5			,			_lowercase   :    Tuple=0.0			,			_lowercase   :    Any=0.0_2			,			_lowercase   :    List[Any]=1.0			,			_lowercase   :    Any=0			,			_lowercase   :    Union[str, Any]=49_406			,			_lowercase   :    Dict=49_407			,			**_lowercase   :    List[Any]			,			):
								super().__init__(pad_token_id=_lowercase			,			bos_token_id=_lowercase			,			eos_token_id=_lowercase			,			**_lowercase		)

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







						@classmethod
						def __a						(							cls   :    Tuple			,			_lowercase   :    Union[str, os.PathLike]			,			**_lowercase   :    Dict		):
								cls._set_token_in_kwargs(_lowercase		)

								A       , A					       = cls.get_config_dict(_lowercase			,			**_lowercase		)

								# get the text config dict if we are loading from OwlViTConfig
								if config_dict.get('model_type'		) == "owlvit":
										A					       = 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 			lowerCamelCase__						(   UpperCAmelCase_			):
						lowerCAmelCase       =     """owlvit_vision_model"""







						def __init__(							self   :    Tuple			,			_lowercase   :    str=768			,			_lowercase   :    Optional[int]=3_072			,			_lowercase   :    Dict=12			,			_lowercase   :    int=12			,			_lowercase   :    Any=3			,			_lowercase   :    int=768			,			_lowercase   :    Optional[int]=32			,			_lowercase   :    Any="quick_gelu"			,			_lowercase   :    List[str]=1e-5			,			_lowercase   :    Optional[Any]=0.0			,			_lowercase   :    List[Any]=0.0_2			,			_lowercase   :    Dict=1.0			,			**_lowercase   :    List[Any]			,			):
								super().__init__(**_lowercase		)

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







						@classmethod
						def __a						(							cls   :    int			,			_lowercase   :    Union[str, os.PathLike]			,			**_lowercase   :    Union[str, Any]		):
								cls._set_token_in_kwargs(_lowercase		)

								A       , A					       = cls.get_config_dict(_lowercase			,			**_lowercase		)

								# get the vision config dict if we are loading from OwlViTConfig
								if config_dict.get('model_type'		) == "owlvit":
										A					       = 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 			lowerCamelCase__						(   UpperCAmelCase_			):
						lowerCAmelCase       =     """owlvit"""
						lowerCAmelCase       =     True







						def __init__(							self   :    Tuple			,			_lowercase   :    Optional[Any]=None			,			_lowercase   :    List[Any]=None			,			_lowercase   :    Tuple=512			,			_lowercase   :    int=2.6_5_9_2			,			_lowercase   :    int=True			,			**_lowercase   :    Any			,			):
								super().__init__(**_lowercase		)

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

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

								A					       = OwlViTTextConfig(**_lowercase		)
								A					       = OwlViTVisionConfig(**_lowercase		)

								A					       = projection_dim
								A					       = logit_scale_init_value
								A					       = return_dict
								A					       = 1.0







						@classmethod
						def __a						(							cls   :    Union[str, Any]			,			_lowercase   :    Union[str, os.PathLike]			,			**_lowercase   :    List[Any]		):
								cls._set_token_in_kwargs(_lowercase		)

								A       , A					       = 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[Any]			,			_lowercase   :    Dict			,			_lowercase   :    Dict			,			**_lowercase   :    Tuple		):
								A					       = {}
								A					       = text_config
								A					       = vision_config

								return cls.from_dict(_lowercase			,			**_lowercase		)







						def __a						(							self   :    Optional[Any]		):
								A					       = copy.deepcopy(self.__dict__		)
								A					       = self.text_config.to_dict()
								A					       = self.vision_config.to_dict()
								A					       = self.__class__.model_type
								return output



class 			lowerCamelCase__						(   UpperCAmelCase_			):







						@property
						def __a						(							self   :    Tuple		):
								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   :    List[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   :    str		):
								return 1e-4







						def __a						(							self   :    List[str]			,			_lowercase   :    "ProcessorMixin"			,			_lowercase   :    int = -1			,			_lowercase   :    int = -1			,			_lowercase   :    Optional["TensorType"] = None			,			):
								A					       = super().generate_dummy_inputs(
								    processor.tokenizer			,			batch_size=_lowercase			,			seq_length=_lowercase			,			framework=_lowercase		)
								A					       = super().generate_dummy_inputs(
								    processor.image_processor			,			batch_size=_lowercase			,			framework=_lowercase		)
								return {**text_input_dict, **image_input_dict}







						@property
						def __a						(							self   :    Dict		):
								return 14









"""simple docstring"""


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


UpperCamelCase						:				Dict             =      {
    "configuration_megatron_bert": ["MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MegatronBertConfig"],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	UpperCamelCase						:				Any             =      [
	    "MEGATRON_BERT_PRETRAINED_MODEL_ARCHIVE_LIST",
	    "MegatronBertForCausalLM",
	    "MegatronBertForMaskedLM",
	    "MegatronBertForMultipleChoice",
	    "MegatronBertForNextSentencePrediction",
	    "MegatronBertForPreTraining",
	    "MegatronBertForQuestionAnswering",
	    "MegatronBertForSequenceClassification",
	    "MegatronBertForTokenClassification",
	    "MegatronBertModel",
	    "MegatronBertPreTrainedModel",
	]

if TYPE_CHECKING:
	from .configuration_megatron_bert import MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, MegatronBertConfig

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_megatron_bert import (
		    MEGATRON_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    MegatronBertForCausalLM,
		    MegatronBertForMaskedLM,
		    MegatronBertForMultipleChoice,
		    MegatronBertForNextSentencePrediction,
		    MegatronBertForPreTraining,
		    MegatronBertForQuestionAnswering,
		    MegatronBertForSequenceClassification,
		    MegatronBertForTokenClassification,
		    MegatronBertModel,
		    MegatronBertPreTrainedModel,
		)

else:
	import sys

	UpperCamelCase						:				Dict             =      _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





