




'''simple docstring'''


import shutil
import tempfile
import unittest

import numpy as np
import pytest

from transformers.testing_utils import require_vision
from transformers.utils import is_vision_available


if is_vision_available():
				from PIL import Image

				from transformers import AutoProcessor, BertTokenizer, BlipImageProcessor, BlipProcessor, PreTrainedTokenizerFast

@require_vision
class      A       (						unittest.TestCase       ):







							def   __lowerCAmelCase     (    self			:    Any   )     ->				Tuple:


														"""simple docstring"""


														_a      	=							tempfile.mkdtemp()

														_a      	=							BlipImageProcessor()
														_a      	=							BertTokenizer.from_pretrained('''hf-internal-testing/tiny-random-BertModel'''   )

														_a      	=							BlipProcessor(lowerCAmelCase_				,     lowerCAmelCase_   )

														processor.save_pretrained(self.tmpdirname   )







							def   __lowerCAmelCase     (    self			:    List[Any]				,     **lowerCAmelCase_			:    List[str]   )     ->				str:


														"""simple docstring"""


														return AutoProcessor.from_pretrained(self.tmpdirname				,     **lowerCAmelCase_   ).tokenizer







							def   __lowerCAmelCase     (    self			:    int				,     **lowerCAmelCase_			:    Optional[int]   )     ->				Any:


														"""simple docstring"""


														return AutoProcessor.from_pretrained(self.tmpdirname				,     **lowerCAmelCase_   ).image_processor







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


														"""simple docstring"""


														shutil.rmtree(self.tmpdirname   )







							def   __lowerCAmelCase     (    self			:    List[str]   )     ->				Any:


														"""simple docstring"""


														_a      	=							[np.random.randint(2_55				,     size=(3, 30, 4_00)				,     dtype=np.uinta   )]

														_a      	=							[Image.fromarray(np.moveaxis(lowerCAmelCase_				,     0				,     -1   )   ) for x in image_inputs]

														return image_inputs







							def   __lowerCAmelCase     (    self			:    List[Any]   )     ->				int:


														"""simple docstring"""


														_a      	=							BlipProcessor(tokenizer=self.get_tokenizer()				,     image_processor=self.get_image_processor()   )
														processor.save_pretrained(self.tmpdirname   )

														_a      	=							self.get_tokenizer(bos_token='''(BOS)'''				,     eos_token='''(EOS)'''   )
														_a      	=							self.get_image_processor(do_normalize=lowerCAmelCase_				,     padding_value=1.0   )

														_a      	=							BlipProcessor.from_pretrained(
														    self.tmpdirname				,     bos_token='''(BOS)'''				,     eos_token='''(EOS)'''				,     do_normalize=lowerCAmelCase_				,     padding_value=1.0   )

														self.assertEqual(processor.tokenizer.get_vocab()				,     tokenizer_add_kwargs.get_vocab()   )
														self.assertIsInstance(processor.tokenizer				,     lowerCAmelCase_   )

														self.assertEqual(processor.image_processor.to_json_string()				,     image_processor_add_kwargs.to_json_string()   )
														self.assertIsInstance(processor.image_processor				,     lowerCAmelCase_   )







							def   __lowerCAmelCase     (    self			:    Any   )     ->				Any:


														"""simple docstring"""


														_a      	=							self.get_image_processor()
														_a      	=							self.get_tokenizer()

														_a      	=							BlipProcessor(tokenizer=lowerCAmelCase_				,     image_processor=lowerCAmelCase_   )

														_a      	=							self.prepare_image_inputs()

														_a      	=							image_processor(lowerCAmelCase_				,     return_tensors='''np'''   )
														_a      	=							processor(images=lowerCAmelCase_				,     return_tensors='''np'''   )

														for key in input_feat_extract.keys():
																					self.assertAlmostEqual(input_feat_extract[key].sum()				,     input_processor[key].sum()				,     delta=1e-2   )







							def   __lowerCAmelCase     (    self			:    str   )     ->				Optional[int]:


														"""simple docstring"""


														_a      	=							self.get_image_processor()
														_a      	=							self.get_tokenizer()

														_a      	=							BlipProcessor(tokenizer=lowerCAmelCase_				,     image_processor=lowerCAmelCase_   )

														_a      	=							'''lower newer'''

														_a      	=							processor(text=lowerCAmelCase_   )

														_a      	=							tokenizer(lowerCAmelCase_				,     return_token_type_ids=lowerCAmelCase_   )

														for key in encoded_tok.keys():
																					self.assertListEqual(encoded_tok[key]				,     encoded_processor[key]   )







							def   __lowerCAmelCase     (    self			:    str   )     ->				Optional[int]:


														"""simple docstring"""


														_a      	=							self.get_image_processor()
														_a      	=							self.get_tokenizer()

														_a      	=							BlipProcessor(tokenizer=lowerCAmelCase_				,     image_processor=lowerCAmelCase_   )

														_a      	=							'''lower newer'''
														_a      	=							self.prepare_image_inputs()

														_a      	=							processor(text=lowerCAmelCase_				,     images=lowerCAmelCase_   )

														self.assertListEqual(list(inputs.keys()   )				,     ['''pixel_values''', '''input_ids''', '''attention_mask''']   )

														# test if it raises when no input is passed
														with pytest.raises(lowerCAmelCase_   ):
																					processor()







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


														"""simple docstring"""


														_a      	=							self.get_image_processor()
														_a      	=							self.get_tokenizer()

														_a      	=							BlipProcessor(tokenizer=lowerCAmelCase_				,     image_processor=lowerCAmelCase_   )

														_a      	=							[[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

														_a      	=							processor.batch_decode(lowerCAmelCase_   )
														_a      	=							tokenizer.batch_decode(lowerCAmelCase_   )

														self.assertListEqual(lowerCAmelCase_				,     lowerCAmelCase_   )







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


														"""simple docstring"""


														_a      	=							self.get_image_processor()
														_a      	=							self.get_tokenizer()

														_a      	=							BlipProcessor(tokenizer=lowerCAmelCase_				,     image_processor=lowerCAmelCase_   )

														_a      	=							'''lower newer'''
														_a      	=							self.prepare_image_inputs()

														_a      	=							processor(text=lowerCAmelCase_				,     images=lowerCAmelCase_   )

														# For now the processor supports only ['pixel_values', 'input_ids', 'attention_mask']
														self.assertListEqual(list(inputs.keys()   )				,     ['''pixel_values''', '''input_ids''', '''attention_mask''']   )







'''simple docstring'''


import qiskit
def 						snake_case_       (UpperCamelCase			:    int					,		UpperCamelCase			:    int ):





							'''simple docstring'''


							_a      	=							qiskit.Aer.get_backend('''aer_simulator''' )

							_a      	=							qiskit.QuantumCircuit(4					,		2 )
							# encode inputs in qubits 0 and 1
							if bita == 1:
														qc_ha.x(0 )
							if bita == 1:
														qc_ha.x(1 )
							qc_ha.barrier()

							# use cnots to write XOR of the inputs on qubit2
							qc_ha.cx(0					,		2 )
							qc_ha.cx(1					,		2 )

							# use ccx / toffoli gate to write AND of the inputs on qubit3
							qc_ha.ccx(0					,		1					,		3 )
							qc_ha.barrier()

							# extract outputs
							qc_ha.measure(2					,		0 )  # extract XOR value
							qc_ha.measure(3					,		1 )  # extract AND value

							# Execute the circuit on the qasm simulator
							_a      	=							qiskit.execute(UpperCamelCase					,		UpperCamelCase					,		shots=1000 )

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


if __name__ == "__main__":
				_snake_case : Tuple  				=						half_adder(1, 1)
				print(F'''Half Adder Output Qubit Counts: {counts}''')

