


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


__snake_case							   =  logging.get_logger(__name__)

__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      lowercase			(							A__      ):

		"""simple docstring"""

		_a									=       'owlvit_text_model'




		def __init__(	self					,     UpperCamelCase_=49408					,     UpperCamelCase_=512					,     UpperCamelCase_=2048					,     UpperCamelCase_=12					,     UpperCamelCase_=8					,     UpperCamelCase_=16					,     UpperCamelCase_="quick_gelu"					,     UpperCamelCase_=1e-5					,     UpperCamelCase_=0.0					,     UpperCamelCase_=0.02					,     UpperCamelCase_=1.0					,     UpperCamelCase_=0					,     UpperCamelCase_=49406					,     UpperCamelCase_=49407					,     **UpperCamelCase_					,     ):

							'''simple docstring'''


							super().__init__(pad_token_id=UpperCamelCase_					,     bos_token_id=UpperCamelCase_					,     eos_token_id=UpperCamelCase_					,     **UpperCamelCase_							)

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




		@classmethod
		def 					lowerCAmelCase__       (	cls					,     UpperCamelCase_					,     **UpperCamelCase_							):

							'''simple docstring'''


							cls._set_token_in_kwargs(UpperCamelCase_							)

							UpperCamelCase__      ,       UpperCamelCase__     :Tuple							      =				cls.get_config_dict(UpperCamelCase_					,     **UpperCamelCase_							)

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



class      lowercase			(							A__      ):

		"""simple docstring"""

		_a									=       'owlvit_vision_model'




		def __init__(	self					,     UpperCamelCase_=768					,     UpperCamelCase_=3072					,     UpperCamelCase_=12					,     UpperCamelCase_=12					,     UpperCamelCase_=3					,     UpperCamelCase_=768					,     UpperCamelCase_=32					,     UpperCamelCase_="quick_gelu"					,     UpperCamelCase_=1e-5					,     UpperCamelCase_=0.0					,     UpperCamelCase_=0.02					,     UpperCamelCase_=1.0					,     **UpperCamelCase_					,     ):

							'''simple docstring'''


							super().__init__(**UpperCamelCase_							)

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




		@classmethod
		def 					lowerCAmelCase__       (	cls					,     UpperCamelCase_					,     **UpperCamelCase_							):

							'''simple docstring'''


							cls._set_token_in_kwargs(UpperCamelCase_							)

							UpperCamelCase__      ,       UpperCamelCase__     :List[Any]							      =				cls.get_config_dict(UpperCamelCase_					,     **UpperCamelCase_							)

							# get the vision config dict if we are loading from OwlViTConfig
							if config_dict.get('''model_type'''							) == "owlvit":
												UpperCamelCase__     :Optional[Any]							      =				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(UpperCamelCase_					,     **UpperCamelCase_							)



class      lowercase			(							A__      ):

		"""simple docstring"""

		_a									=       'owlvit'
		_a									=       True




		def __init__(	self					,     UpperCamelCase_=None					,     UpperCamelCase_=None					,     UpperCamelCase_=512					,     UpperCamelCase_=2.6592					,     UpperCamelCase_=True					,     **UpperCamelCase_					,     ):

							'''simple docstring'''


							super().__init__(**UpperCamelCase_							)

							if text_config is None:
												UpperCamelCase__     :List[Any]							      =				{}
												logger.info('''text_config is None. Initializing the OwlViTTextConfig with default values.'''							)

							if vision_config is None:
												UpperCamelCase__     :List[str]							      =				{}
												logger.info('''vision_config is None. initializing the OwlViTVisionConfig with default values.'''							)

							UpperCamelCase__     :Optional[int]							      =				OwlViTTextConfig(**UpperCamelCase_							)
							UpperCamelCase__     :int							      =				OwlViTVisionConfig(**UpperCamelCase_							)

							UpperCamelCase__     :Optional[Any]							      =				projection_dim
							UpperCamelCase__     :List[Any]							      =				logit_scale_init_value
							UpperCamelCase__     :str							      =				return_dict
							UpperCamelCase__     :Any							      =				1.0




		@classmethod
		def 					lowerCAmelCase__       (	cls					,     UpperCamelCase_					,     **UpperCamelCase_							):

							'''simple docstring'''


							cls._set_token_in_kwargs(UpperCamelCase_							)

							UpperCamelCase__      ,       UpperCamelCase__     :Any							      =				cls.get_config_dict(UpperCamelCase_					,     **UpperCamelCase_							)

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




		@classmethod
		def 					lowerCAmelCase__       (	cls					,     UpperCamelCase_					,     UpperCamelCase_					,     **UpperCamelCase_							):

							'''simple docstring'''


							UpperCamelCase__     :Dict							      =				{}
							UpperCamelCase__     :int							      =				text_config
							UpperCamelCase__     :int							      =				vision_config

							return cls.from_dict(UpperCamelCase_					,     **UpperCamelCase_							)




		def 					lowerCAmelCase__       (	self							):

							'''simple docstring'''


							UpperCamelCase__     :Dict							      =				copy.deepcopy(self.__dict__							)
							UpperCamelCase__     :Union[str, Any]							      =				self.text_config.to_dict()
							UpperCamelCase__     :Optional[Any]							      =				self.vision_config.to_dict()
							UpperCamelCase__     :Dict							      =				self.__class__.model_type
							return output



class      lowercase			(							A__      ):

		"""simple docstring"""

		@property
		def 					lowerCAmelCase__       (	self							):

							'''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 					lowerCAmelCase__       (	self							):

							'''simple docstring'''


							return OrderedDict(
							    [
							        ('''logits_per_image''', {0: '''batch'''}),
							        ('''logits_per_text''', {0: '''batch'''}),
							        ('''text_embeds''', {0: '''batch'''}),
							        ('''image_embeds''', {0: '''batch'''}),
							    ]							)




		@property
		def 					lowerCAmelCase__       (	self							):

							'''simple docstring'''


							return 1e-4




		def 					lowerCAmelCase__       (	self					,     UpperCamelCase_					,     UpperCamelCase_ = -1					,     UpperCamelCase_ = -1					,     UpperCamelCase_ = None					,     ):

							'''simple docstring'''


							UpperCamelCase__     :Optional[int]							      =				super().generate_dummy_inputs(
							    processor.tokenizer					,     batch_size=UpperCamelCase_					,     seq_length=UpperCamelCase_					,     framework=UpperCamelCase_							)
							UpperCamelCase__     :str							      =				super().generate_dummy_inputs(
							    processor.image_processor					,     batch_size=UpperCamelCase_					,     framework=UpperCamelCase_							)
							return {**text_input_dict, **image_input_dict}




		@property
		def 					lowerCAmelCase__       (	self							):

							'''simple docstring'''


							return 14



'''simple docstring'''
import qiskit


def     a   (    __a				,      __a     )						->			qiskit.result.counts.Counts:



					'''simple docstring'''






					UpperCamelCase__     :int							      =				qiskit.Aer.get_backend('''aer_simulator'''     )

					# Create a Quantum Circuit acting on the q register
					UpperCamelCase__     :Any							      =				qiskit.QuantumCircuit(__a				,      __a     )

					# Map the quantum measurement to the classical bits
					circuit.measure([0]				,      [0]     )

					# Execute the circuit on the simulator
					UpperCamelCase__     :Optional[int]							      =				qiskit.execute(__a				,      __a				,      shots=1000     )

					# Return the histogram data of the results of the experiment.
					return job.result().get_counts(__a     )


if __name__ == "__main__":
		print(F"""Total count for various states are: {single_qubit_measure(1, 1)}""")