






"""simple docstring"""



import unittest

import numpy as np

from transformers import BlipTextConfig
from transformers.testing_utils import require_torch, slow, torch_device
from transformers.utils import is_torch_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask


if is_torch_available():
						import torch

						from transformers import BlipTextModel
						from transformers.models.blip.modeling_blip import BLIP_PRETRAINED_MODEL_ARCHIVE_LIST




class        __lowercase:






						def __init__(					self    ,						_SCREAMING_SNAKE_CASE    ,						_SCREAMING_SNAKE_CASE=12    ,						_SCREAMING_SNAKE_CASE=7    ,						_SCREAMING_SNAKE_CASE=True    ,						_SCREAMING_SNAKE_CASE=True    ,						_SCREAMING_SNAKE_CASE=True    ,						_SCREAMING_SNAKE_CASE=99    ,						_SCREAMING_SNAKE_CASE=32    ,						_SCREAMING_SNAKE_CASE=32    ,						_SCREAMING_SNAKE_CASE=5    ,						_SCREAMING_SNAKE_CASE=4    ,						_SCREAMING_SNAKE_CASE=37    ,						_SCREAMING_SNAKE_CASE=0.1    ,						_SCREAMING_SNAKE_CASE=0.1    ,						_SCREAMING_SNAKE_CASE=5_12    ,						_SCREAMING_SNAKE_CASE=0.02    ,						_SCREAMING_SNAKE_CASE=0    ,						_SCREAMING_SNAKE_CASE=None    ,						)			->  Dict:




											"""simple docstring"""





											lowerCamelCase__				=parent
											lowerCamelCase__				=batch_size
											lowerCamelCase__				=seq_length
											lowerCamelCase__				=is_training
											lowerCamelCase__				=use_input_mask
											lowerCamelCase__				=use_labels
											lowerCamelCase__				=vocab_size
											lowerCamelCase__				=hidden_size
											lowerCamelCase__				=projection_dim
											lowerCamelCase__				=num_hidden_layers
											lowerCamelCase__				=num_attention_heads
											lowerCamelCase__				=intermediate_size
											lowerCamelCase__				=dropout
											lowerCamelCase__				=attention_dropout
											lowerCamelCase__				=max_position_embeddings
											lowerCamelCase__				=initializer_range
											lowerCamelCase__				=scope
											lowerCamelCase__				=bos_token_id






						def 		lowerCAmelCase   (					self)			->  str:




											"""simple docstring"""





											lowerCamelCase__				=ids_tensor([self.batch_size, self.seq_length]    ,						self.vocab_size)

											lowerCamelCase__				=None
											if self.use_input_mask:
																lowerCamelCase__				=random_attention_mask([self.batch_size, self.seq_length])

											if input_mask is not None:
																lowerCamelCase__				,     lowerCamelCase__				=input_mask.shape
																lowerCamelCase__				=np.random.randint(1    ,						seq_length - 1    ,						size=(batch_size,))
																for batch_idx, start_index in enumerate(_SCREAMING_SNAKE_CASE):
																					lowerCamelCase__				=1
																					lowerCamelCase__				=0

											lowerCamelCase__				=self.get_config()

											return config, input_ids, input_mask






						def 		lowerCAmelCase   (					self)			->  List[str]:




											"""simple docstring"""





											return BlipTextConfig(
											    vocab_size=self.vocab_size    ,						hidden_size=self.hidden_size    ,						projection_dim=self.projection_dim    ,						num_hidden_layers=self.num_hidden_layers    ,						num_attention_heads=self.num_attention_heads    ,						intermediate_size=self.intermediate_size    ,						dropout=self.dropout    ,						attention_dropout=self.attention_dropout    ,						max_position_embeddings=self.max_position_embeddings    ,						initializer_range=self.initializer_range    ,						bos_token_id=self.bos_token_id    ,						)






						def 		lowerCAmelCase   (					self    ,						_SCREAMING_SNAKE_CASE    ,						_SCREAMING_SNAKE_CASE    ,						_SCREAMING_SNAKE_CASE)			->  Optional[Any]:




											"""simple docstring"""





											lowerCamelCase__				=BlipTextModel(config=_SCREAMING_SNAKE_CASE)
											model.to(_SCREAMING_SNAKE_CASE)
											model.eval()
											with torch.no_grad():
																lowerCamelCase__				=model(_SCREAMING_SNAKE_CASE    ,						attention_mask=_SCREAMING_SNAKE_CASE)
																lowerCamelCase__				=model(_SCREAMING_SNAKE_CASE)
											self.parent.assertEqual(result.last_hidden_state.shape    ,						(self.batch_size, self.seq_length, self.hidden_size))
											self.parent.assertEqual(result.pooler_output.shape    ,						(self.batch_size, self.hidden_size))






						def 		lowerCAmelCase   (					self)			->  Dict:




											"""simple docstring"""





											lowerCamelCase__				=self.prepare_config_and_inputs()
											lowerCamelCase__				,     lowerCamelCase__				,     lowerCamelCase__				=config_and_inputs
											lowerCamelCase__				={'input_ids': input_ids, 'attention_mask': input_mask}
											return config, inputs_dict




@require_torch
class        __lowercase(       _UpperCamelCase						,							unittest.TestCase  ):
						lowerCAmelCase_		:							Optional[Any]=       (BlipTextModel,) if is_torch_available() else ()
						lowerCAmelCase_		:							Optional[int]=       False
						lowerCAmelCase_		:							Any=       False
						lowerCAmelCase_		:							Dict=       False






						def 		lowerCAmelCase   (					self)			->  Optional[Any]:




											"""simple docstring"""





											lowerCamelCase__				=BlipTextModelTester(self)
											lowerCamelCase__				=ConfigTester(self    ,						config_class=_SCREAMING_SNAKE_CASE    ,						hidden_size=37)






						def 		lowerCAmelCase   (					self)			->  Dict:




											"""simple docstring"""





											self.config_tester.run_common_tests()






						def 		lowerCAmelCase   (					self)			->  str:




											"""simple docstring"""





											lowerCamelCase__				=self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_model(*_SCREAMING_SNAKE_CASE)






						def 		lowerCAmelCase   (					self)			->  Optional[int]:




											"""simple docstring"""





											pass






						def 		lowerCAmelCase   (					self)			->  str:




											"""simple docstring"""





											pass






						@unittest.skip(reason='Blip does not use inputs_embeds')
						def 		lowerCAmelCase   (					self)			->  List[Any]:




											"""simple docstring"""





											pass






						@unittest.skip(reason='BlipTextModel has no base class and is not available in MODEL_MAPPING')
						def 		lowerCAmelCase   (					self)			->  Union[str, Any]:




											"""simple docstring"""





											pass






						@unittest.skip(reason='BlipTextModel has no base class and is not available in MODEL_MAPPING')
						def 		lowerCAmelCase   (					self)			->  List[Any]:




											"""simple docstring"""





											pass






						@slow
						def 		lowerCAmelCase   (					self)			->  Union[str, Any]:




											"""simple docstring"""





											for model_name in BLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																lowerCamelCase__				=BlipTextModel.from_pretrained(_SCREAMING_SNAKE_CASE)
																self.assertIsNotNone(_SCREAMING_SNAKE_CASE)






						def 		lowerCAmelCase   (					self)			->  Union[str, Any]:




											"""simple docstring"""





											super().test_pt_tf_model_equivalence(allow_missing_keys=_SCREAMING_SNAKE_CASE)







"""simple docstring"""



import math

import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute




def 						lowerCamelCase_				(  __A  :		int = 1			,	__A  :		int = 1			):
					if isinstance(__A			,	__A			) or isinstance(__A			,	__A			):
										raise TypeError('inputs must be integers.'			)
					if (bit_a < 0) or (bit_a < 0):
										raise ValueError('inputs must be positive.'			)
					if (math.floor(__A			) != bit_a) or (math.floor(__A			) != bit_a):
										raise ValueError('inputs must be exact integers.'			)
					if (bit_a > 1) or (bit_a > 1):
										raise ValueError('inputs must be less or equal to 1.'			)

					# build registers
					lowerCamelCase__				=QuantumRegister(2			,	'qr'			)
					lowerCamelCase__				=ClassicalRegister(2			,	'cr'			)

					lowerCamelCase__				=QuantumCircuit(__A			,	__A			)

					# entanglement the qubits
					quantum_circuit.h(1			)
					quantum_circuit.cx(1			,	0			)

					# send the information
					lowerCamelCase__				=str(__A			) + str(__A			)

					if c_information == "11":
										quantum_circuit.x(1			)
										quantum_circuit.z(1			)
					elif c_information == "10":
										quantum_circuit.z(1			)
					elif c_information == "01":
										quantum_circuit.x(1			)
					else:
										quantum_circuit.i(1			)

					# unentangled the circuit
					quantum_circuit.cx(1			,	0			)
					quantum_circuit.h(1			)

					# measure the circuit
					quantum_circuit.measure(__A			,	__A			)

					lowerCamelCase__				=Aer.get_backend('aer_simulator'			)
					lowerCamelCase__				=execute(__A			,	__A			,	shots=1000			)

					return job.result().get_counts(__A			)


if __name__ == "__main__":
						print(f"Counts for classical state send: {superdense_coding(1,1)}")