"""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[Any]		  =			logging.get_logger(__name__)

lowerCAmelCase__						:						List[str]		  =			{
    '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       ):




					"""simple docstring"""

					snake_case__       					=				"owlvit_text_model"







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

									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 	__lowerCAmelCase		(       cls     :			int					,lowerCamelCase__     :			int					,**lowerCamelCase__     :			str    ):
									cls._set_token_in_kwargs(lowerCamelCase__    )

									UpperCAmelCase__   ,			UpperCAmelCase__    =							cls.get_config_dict(lowerCamelCase__					,**lowerCamelCase__    )

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






class        snake_case (				__UpperCAmelCase       ):




					"""simple docstring"""

					snake_case__       					=				"owlvit_vision_model"







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

									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 	__lowerCAmelCase		(       cls     :			Optional[int]					,lowerCamelCase__     :			str					,**lowerCamelCase__     :			int    ):
									cls._set_token_in_kwargs(lowerCamelCase__    )

									UpperCAmelCase__   ,			UpperCAmelCase__    =							cls.get_config_dict(lowerCamelCase__					,**lowerCamelCase__    )

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






class        snake_case (				__UpperCAmelCase       ):




					"""simple docstring"""

					snake_case__       					=				"owlvit"
					snake_case__       					=				True







					def __init__(       self     :			Optional[int]					,lowerCamelCase__     :			Optional[Any]=None					,lowerCamelCase__     :			str=None					,lowerCamelCase__     :			Dict=512					,lowerCamelCase__     :			str=2.6_5_9_2					,lowerCamelCase__     :			Optional[int]=True					,**lowerCamelCase__     :			int					,):
									super().__init__(**lowerCamelCase__    )

									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(**lowerCamelCase__    )
									UpperCAmelCase__    =							OwlViTVisionConfig(**lowerCamelCase__    )

									UpperCAmelCase__    =							projection_dim
									UpperCAmelCase__    =							logit_scale_init_value
									UpperCAmelCase__    =							return_dict
									UpperCAmelCase__    =							1.0







					@classmethod
					def 	__lowerCAmelCase		(       cls     :			Optional[Any]					,lowerCamelCase__     :			Optional[int]					,**lowerCamelCase__     :			Optional[int]    ):
									cls._set_token_in_kwargs(lowerCamelCase__    )

									UpperCAmelCase__   ,			UpperCAmelCase__    =							cls.get_config_dict(lowerCamelCase__					,**lowerCamelCase__    )

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







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

									return cls.from_dict(lowerCamelCase__					,**lowerCamelCase__    )







					def 	__lowerCAmelCase		(       self     :			Any    ):
									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        snake_case (				__UpperCAmelCase       ):




					"""simple docstring"""

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







					@property
					def 	__lowerCAmelCase		(       self     :			Dict    ):
									return 1e-4







					def 	__lowerCAmelCase		(       self     :			Dict					,lowerCamelCase__     :			Union[str, Any]					,lowerCamelCase__     :			str = -1					,lowerCamelCase__     :			Optional[Any] = -1					,lowerCamelCase__     :			Any = None					,):
									UpperCAmelCase__    =							super().generate_dummy_inputs(
									    processor.tokenizer					,batch_size=lowerCamelCase__					,seq_length=lowerCamelCase__					,framework=lowerCamelCase__    )
									UpperCAmelCase__    =							super().generate_dummy_inputs(
									    processor.image_processor					,batch_size=lowerCamelCase__					,framework=lowerCamelCase__    )
									return {**text_input_dict, **image_input_dict}







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




"""simple docstring"""






from __future__ import annotations

from math import ceil, floor, sqrt



def 						a_		(      lowerCamelCase = 2_0_0_0_0_0_0 ):
				UpperCAmelCase__    =							[0]
				UpperCAmelCase__    =							42

				for idx in range(1      ,    ceil(sqrt(target * 2 ) * 1.1 ) ):
								triangle_numbers.append(triangle_numbers[-1] + idx )

				# we want this to be as close as possible to target
				UpperCAmelCase__    =							0
				# the area corresponding to the grid that gives the product closest to target
				UpperCAmelCase__    =							0
				# an estimate of b, using the quadratic formula
				UpperCAmelCase__    =							42
				# the largest integer less than b_estimate
				UpperCAmelCase__    =							42
				# the largest integer less than b_estimate
				UpperCAmelCase__    =							42
				# the triangle number corresponding to b_floor
				UpperCAmelCase__    =							42
				# the triangle number corresponding to b_ceil
				UpperCAmelCase__    =							42

				for idx_a, triangle_a in enumerate(triangle_numbers[1:]      ,    1 ):
								UpperCAmelCase__    =							(-1 + sqrt(1 + 8 * target / triangle_a )) / 2
								UpperCAmelCase__    =							floor(lowerCamelCase )
								UpperCAmelCase__    =							ceil(lowerCamelCase )
								UpperCAmelCase__    =							triangle_numbers[b_floor]
								UpperCAmelCase__    =							triangle_numbers[b_ceil]

								if abs(target - triangle_b_first_guess * triangle_a ) < abs(
								    target - best_product ):
												UpperCAmelCase__    =							triangle_b_first_guess * triangle_a
												UpperCAmelCase__    =							idx_a * b_floor

								if abs(target - triangle_b_second_guess * triangle_a ) < abs(
								    target - best_product ):
												UpperCAmelCase__    =							triangle_b_second_guess * triangle_a
												UpperCAmelCase__    =							idx_a * b_ceil

				return area


if __name__ == "__main__":
						print(F"""{solution() = }""")



