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


_a														=		logging.get_logger(__name__)

_a														=		{
    """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     _UpperCAmelCase(    lowerCamelCase	):
		lowercase__						=      'owlvit_text_model'



		def __init__(					self				,		__a=4_94_08				,		__a=5_12				,		__a=20_48				,		__a=12				,		__a=8				,		__a=16				,		__a="quick_gelu"				,		__a=1e-5				,		__a=0.0				,		__a=0.02				,		__a=1.0				,		__a=0				,		__a=4_94_06				,		__a=4_94_07				,		**__a				,		)       ->       List[str]:






							'''simple docstring'''
							super().__init__(pad_token_id=__a				,		bos_token_id=__a				,		eos_token_id=__a				,		**__a)

							_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 						UpperCAmelCase							(					cls				,		__a				,		**__a)       ->       "PretrainedConfig":






							'''simple docstring'''
							cls._set_token_in_kwargs(__a)

							_UpperCamelCase ,  _UpperCamelCase							 =  cls.get_config_dict(__a				,		**__a)

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






class     _UpperCAmelCase(    lowerCamelCase	):
		lowercase__						=      'owlvit_vision_model'



		def __init__(					self				,		__a=7_68				,		__a=30_72				,		__a=12				,		__a=12				,		__a=3				,		__a=7_68				,		__a=32				,		__a="quick_gelu"				,		__a=1e-5				,		__a=0.0				,		__a=0.02				,		__a=1.0				,		**__a				,		)       ->       Union[str, Any]:






							'''simple docstring'''
							super().__init__(**__a)

							_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 						UpperCAmelCase							(					cls				,		__a				,		**__a)       ->       "PretrainedConfig":






							'''simple docstring'''
							cls._set_token_in_kwargs(__a)

							_UpperCamelCase ,  _UpperCamelCase							 =  cls.get_config_dict(__a				,		**__a)

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






class     _UpperCAmelCase(    lowerCamelCase	):
		lowercase__						=      'owlvit'
		lowercase__						=      True



		def __init__(					self				,		__a=None				,		__a=None				,		__a=5_12				,		__a=2.6592				,		__a=True				,		**__a				,		)       ->       int:






							'''simple docstring'''
							super().__init__(**__a)

							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(**__a)
							_UpperCamelCase							 =  OwlViTVisionConfig(**__a)

							_UpperCamelCase							 =  projection_dim
							_UpperCamelCase							 =  logit_scale_init_value
							_UpperCamelCase							 =  return_dict
							_UpperCamelCase							 =  1.0



		@classmethod
		def 						UpperCAmelCase							(					cls				,		__a				,		**__a)       ->       "PretrainedConfig":






							'''simple docstring'''
							cls._set_token_in_kwargs(__a)

							_UpperCamelCase ,  _UpperCamelCase							 =  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				,		__a				,		__a				,		**__a)       ->       Any:






							'''simple docstring'''
							_UpperCamelCase							 =  {}
							_UpperCamelCase							 =  text_config
							_UpperCamelCase							 =  vision_config

							return cls.from_dict(__a				,		**__a)




		def 						UpperCAmelCase							(					self)       ->       Tuple:






							'''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     _UpperCAmelCase(    lowerCamelCase	):



		@property
		def 						UpperCAmelCase							(					self)       ->       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 						UpperCAmelCase							(					self)       ->       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 						UpperCAmelCase							(					self)       ->       float:






							'''simple docstring'''
							return 1e-4



		def 						UpperCAmelCase							(					self				,		__a				,		__a = -1				,		__a = -1				,		__a = None				,		)       ->       Mapping[str, Any]:






							'''simple docstring'''
							_UpperCamelCase							 =  super().generate_dummy_inputs(
							    processor.tokenizer				,		batch_size=__a				,		seq_length=__a				,		framework=__a)
							_UpperCamelCase							 =  super().generate_dummy_inputs(
							    processor.image_processor				,		batch_size=__a				,		framework=__a)
							return {**text_input_dict, **image_input_dict}




		@property
		def 						UpperCAmelCase							(					self)       ->       int:






							'''simple docstring'''
							return 14








"""simple docstring"""





from graphs.minimum_spanning_tree_kruskal import kruskal



def       lowerCamelCase__		(			)							->		List[Any]:


					"""simple docstring"""





					_UpperCamelCase							 =  9
					_UpperCamelCase							 =  [
					    [0, 1, 4],
					    [0, 7, 8],
					    [1, 2, 8],
					    [7, 8, 7],
					    [7, 6, 1],
					    [2, 8, 2],
					    [8, 6, 6],
					    [2, 3, 7],
					    [2, 5, 4],
					    [6, 5, 2],
					    [3, 5, 14],
					    [3, 4, 9],
					    [5, 4, 10],
					    [1, 7, 11],
					]

					_UpperCamelCase							 =  kruskal(__snake_case,     __snake_case	)

					_UpperCamelCase							 =  [
					    [7, 6, 1],
					    [2, 8, 2],
					    [6, 5, 2],
					    [0, 1, 4],
					    [2, 5, 4],
					    [2, 3, 7],
					    [0, 7, 8],
					    [3, 4, 9],
					]

					assert sorted(__snake_case	) == sorted(__snake_case	)






