



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


A__  :  Any								=					logging.get_logger(__name__)

A__  :  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 				__snake_case						(     UpperCamelCase_						):
							_a			      = '''owlvit_text_model'''




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

									lowerCAmelCase_			:     List[str]									= vocab_size
									lowerCAmelCase_			:     str									= hidden_size
									lowerCAmelCase_			:     List[Any]									= intermediate_size
									lowerCAmelCase_			:     Dict									= num_hidden_layers
									lowerCAmelCase_			:     List[Any]									= num_attention_heads
									lowerCAmelCase_			:     List[str]									= max_position_embeddings
									lowerCAmelCase_			:     List[str]									= hidden_act
									lowerCAmelCase_			:     List[Any]									= layer_norm_eps
									lowerCAmelCase_			:     Optional[Any]									= attention_dropout
									lowerCAmelCase_			:     str									= initializer_range
									lowerCAmelCase_			:     Union[str, Any]									= initializer_factor







							@classmethod
							def    UpperCAmelCase__			(       cls     :       Union[str, Any]				,				A_     :       Union[str, os.PathLike]				,				**A_     :       Tuple):
									cls._set_token_in_kwargs(A_)

									lowerCAmelCase_					,  lowerCAmelCase_			:     List[Any]									= cls.get_config_dict(A_				,				**A_)

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





class 				__snake_case						(     UpperCamelCase_						):
							_a			      = '''owlvit_vision_model'''




							def __init__(       self     :       int				,				A_     :       Dict=7_6_8				,				A_     :       int=3_0_7_2				,				A_     :       Optional[int]=1_2				,				A_     :       str=1_2				,				A_     :       List[Any]=3				,				A_     :       int=7_6_8				,				A_     :       Any=3_2				,				A_     :       List[Any]="quick_gelu"				,				A_     :       int=1e-5				,				A_     :       Optional[int]=0.0				,				A_     :       Any=0.02				,				A_     :       Dict=1.0				,				**A_     :       int				,				):
									super().__init__(**A_)

									lowerCAmelCase_			:     str									= hidden_size
									lowerCAmelCase_			:     Any									= intermediate_size
									lowerCAmelCase_			:     Any									= num_hidden_layers
									lowerCAmelCase_			:     Dict									= num_attention_heads
									lowerCAmelCase_			:     List[str]									= num_channels
									lowerCAmelCase_			:     Tuple									= image_size
									lowerCAmelCase_			:     Union[str, Any]									= patch_size
									lowerCAmelCase_			:     Optional[Any]									= hidden_act
									lowerCAmelCase_			:     List[Any]									= layer_norm_eps
									lowerCAmelCase_			:     List[Any]									= attention_dropout
									lowerCAmelCase_			:     str									= initializer_range
									lowerCAmelCase_			:     str									= initializer_factor







							@classmethod
							def    UpperCAmelCase__			(       cls     :       Tuple				,				A_     :       Union[str, os.PathLike]				,				**A_     :       Tuple):
									cls._set_token_in_kwargs(A_)

									lowerCAmelCase_					,  lowerCAmelCase_			:     List[str]									= cls.get_config_dict(A_				,				**A_)

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





class 				__snake_case						(     UpperCamelCase_						):
							_a			      = '''owlvit'''
							_a			      = True




							def __init__(       self     :       Dict				,				A_     :       Union[str, Any]=None				,				A_     :       Tuple=None				,				A_     :       Tuple=5_1_2				,				A_     :       Union[str, Any]=2.6592				,				A_     :       str=True				,				**A_     :       Any				,				):
									super().__init__(**A_)

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

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

									lowerCAmelCase_			:     List[str]									= OwlViTTextConfig(**A_)
									lowerCAmelCase_			:     List[str]									= OwlViTVisionConfig(**A_)

									lowerCAmelCase_			:     str									= projection_dim
									lowerCAmelCase_			:     Any									= logit_scale_init_value
									lowerCAmelCase_			:     Any									= return_dict
									lowerCAmelCase_			:     Optional[Any]									= 1.0




							@classmethod
							def    UpperCAmelCase__			(       cls     :       List[str]				,				A_     :       Union[str, os.PathLike]				,				**A_     :       int):
									cls._set_token_in_kwargs(A_)

									lowerCAmelCase_					,  lowerCAmelCase_			:     Optional[int]									= cls.get_config_dict(A_				,				**A_)

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




							@classmethod
							def    UpperCAmelCase__			(       cls     :       List[Any]				,				A_     :       Dict				,				A_     :       Dict				,				**A_     :       str):
									lowerCAmelCase_			:     Optional[int]									= {}
									lowerCAmelCase_			:     Any									= text_config
									lowerCAmelCase_			:     List[str]									= vision_config

									return cls.from_dict(A_				,				**A_)







							def    UpperCAmelCase__			(       self     :       Optional[Any]):
									lowerCAmelCase_			:     Any									= copy.deepcopy(self.__dict__)
									lowerCAmelCase_			:     Any									= self.text_config.to_dict()
									lowerCAmelCase_			:     List[Any]									= self.vision_config.to_dict()
									lowerCAmelCase_			:     List[str]									= self.__class__.model_type
									return output





class 				__snake_case						(     UpperCamelCase_						):




							@property
							def    UpperCAmelCase__			(       self     :       Any):
									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    UpperCAmelCase__			(       self     :       Dict):
									return OrderedDict(
									    [
									        ('''logits_per_image''', {0: '''batch'''}),
									        ('''logits_per_text''', {0: '''batch'''}),
									        ('''text_embeds''', {0: '''batch'''}),
									        ('''image_embeds''', {0: '''batch'''}),
									    ])




							@property
							def    UpperCAmelCase__			(       self     :       List[str]):
									return 1e-4




							def    UpperCAmelCase__			(       self     :       Optional[int]				,				A_     :       "ProcessorMixin"				,				A_     :       int = -1				,				A_     :       int = -1				,				A_     :       Optional["TensorType"] = None				,				):
									lowerCAmelCase_			:     Optional[Any]									= super().generate_dummy_inputs(
									    processor.tokenizer				,				batch_size=A_				,				seq_length=A_				,				framework=A_)
									lowerCAmelCase_			:     int									= super().generate_dummy_inputs(
									    processor.image_processor				,				batch_size=A_				,				framework=A_)
									return {**text_input_dict, **image_input_dict}







							@property
							def    UpperCAmelCase__			(       self     :       Any):
									return 1_4













"""simple docstring"""



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


__A		:       Union[str, Any]  				=		{}

try:
						if not is_sentencepiece_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:       Dict  				=		['''NllbTokenizer''']

try:
						if not is_tokenizers_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						__A		:       Dict  				=		['''NllbTokenizerFast''']


if TYPE_CHECKING:
						try:
												if not is_sentencepiece_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_nllb import NllbTokenizer

						try:
												if not is_tokenizers_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .tokenization_nllb_fast import NllbTokenizerFast

else:
						import sys

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



