
"""simple docstring"""



import math

import qiskit






def 	__snake_case  (    SCREAMING_SNAKE_CASE:					int = 1     ,  SCREAMING_SNAKE_CASE:					int = 1     ,  SCREAMING_SNAKE_CASE:					int = 1						):






							"""simple docstring"""



							if (
							    isinstance(SCREAMING_SNAKE_CASE     ,  SCREAMING_SNAKE_CASE						)
							    or isinstance(SCREAMING_SNAKE_CASE     ,  SCREAMING_SNAKE_CASE						)
							    or isinstance(SCREAMING_SNAKE_CASE     ,  SCREAMING_SNAKE_CASE						)
							):
														raise TypeError('inputs must be integers.'						)

							if (input_a < 0) or (input_a < 0) or (carry_in < 0):
														raise ValueError('inputs must be positive.'						)

							if (
							    (math.floor(SCREAMING_SNAKE_CASE						) != input_a)
							    or (math.floor(SCREAMING_SNAKE_CASE						) != input_a)
							    or (math.floor(SCREAMING_SNAKE_CASE						) != carry_in)
							):
														raise ValueError('inputs must be exact integers.'						)

							if (input_a > 2) or (input_a > 2) or (carry_in > 2):
														raise ValueError('inputs must be less or equal to 2.'						)

							# build registers
							_lowerCAmelCase  	=			qiskit.QuantumRegister(4     ,  'qr'						)
							_lowerCAmelCase  	=			qiskit.ClassicalRegister(2     ,  'cr'						)
							# list the entries
							_lowerCAmelCase  	=			[input_a, input_a, carry_in]

							_lowerCAmelCase  	=			qiskit.QuantumCircuit(SCREAMING_SNAKE_CASE     ,  SCREAMING_SNAKE_CASE						)

							for i in range(0     ,  3						):
														if entry[i] == 2:
																					quantum_circuit.h(SCREAMING_SNAKE_CASE						)  # for hadamard entries
														elif entry[i] == 1:
																					quantum_circuit.x(SCREAMING_SNAKE_CASE						)  # for 1 entries
														elif entry[i] == 0:
																					quantum_circuit.i(SCREAMING_SNAKE_CASE						)  # for 0 entries

    # build the circuit
							quantum_circuit.ccx(0     ,  1     ,  3						)  # ccx = toffoli gate
							quantum_circuit.cx(0     ,  1						)
							quantum_circuit.ccx(1     ,  2     ,  3						)
							quantum_circuit.cx(1     ,  2						)
							quantum_circuit.cx(0     ,  1						)

							quantum_circuit.measure([2, 3]     ,  SCREAMING_SNAKE_CASE						)  # measure the last two qbits

							_lowerCAmelCase  	=			qiskit.Aer.get_backend('aer_simulator'						)
							_lowerCAmelCase  	=			qiskit.execute(SCREAMING_SNAKE_CASE     ,  SCREAMING_SNAKE_CASE     ,  shots=1000						)

							return job.result().get_counts(SCREAMING_SNAKE_CASE						)


if __name__ == "__main__":
	print(f'Total sum count for state is: {quantum_full_adder(1, 1, 1)}')








"""simple docstring"""



import unittest

import numpy as np
import torch

from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad
class        _SCREAMING_SNAKE_CASE  (  unittest.TestCase							):






				'''simple docstring'''



				def 				__lowerCamelCase	(					self	:			Any  )		->  Dict:







											"""simple docstring"""




											_lowerCAmelCase  	=			10


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







											"""simple docstring"""




											_lowerCAmelCase  	=			[1, 2, 3, 4]
											_lowerCAmelCase  	=			[1, 2, 3, 4, 0, 0, 0, 0, 0, 0]
											self.assertEqual(truncate_or_pad(UpperCAmelCase_				,     self.block_size				,     0  )				,     UpperCAmelCase_  )


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







											"""simple docstring"""




											_lowerCAmelCase  	=			[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
											_lowerCAmelCase  	=			[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
											self.assertEqual(truncate_or_pad(UpperCAmelCase_				,     self.block_size				,     0  )				,     UpperCAmelCase_  )


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







											"""simple docstring"""




											_lowerCAmelCase  	=			[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
											_lowerCAmelCase  	=			[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
											self.assertEqual(truncate_or_pad(UpperCAmelCase_				,     self.block_size				,     0  )				,     UpperCAmelCase_  )


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







											"""simple docstring"""




											_lowerCAmelCase  	=			'It was the year of Our Lord one thousand seven hundred and\n        seventy-five.\n\nSpiritual revelations were conceded to England at that\n        favoured period, as at this.'
											_lowerCAmelCase	,		_lowerCAmelCase  	=			process_story(UpperCAmelCase_  )
											self.assertEqual(UpperCAmelCase_				,     []  )


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







											"""simple docstring"""




											_lowerCAmelCase  	=			''
											_lowerCAmelCase	,		_lowerCAmelCase  	=			process_story(UpperCAmelCase_  )
											self.assertEqual(UpperCAmelCase_				,     []  )
											self.assertEqual(UpperCAmelCase_				,     []  )


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







											"""simple docstring"""




											_lowerCAmelCase  	=			(
											    'It was the year of Our Lord one thousand seven hundred and '
											    'seventy-five\n\nSpiritual revelations were conceded to England '
											    'at that favoured period, as at this.\n@highlight\n\nIt was the best of times'
											)
											_lowerCAmelCase	,		_lowerCAmelCase  	=			process_story(UpperCAmelCase_  )

											_lowerCAmelCase  	=			[
											    'It was the year of Our Lord one thousand seven hundred and seventy-five.',
											    'Spiritual revelations were conceded to England at that favoured period, as at this.',
											]
											self.assertEqual(UpperCAmelCase_				,     UpperCAmelCase_  )

											_lowerCAmelCase  	=			['It was the best of times.']
											self.assertEqual(UpperCAmelCase_				,     UpperCAmelCase_  )


				def 				__lowerCamelCase	(					self	:			List[str]  )		->  int:







											"""simple docstring"""




											_lowerCAmelCase  	=			torch.tensor([1, 2, 3, 4]  )
											_lowerCAmelCase  	=			torch.tensor([1, 1, 1, 1]  )
											np.testing.assert_array_equal(build_mask(UpperCAmelCase_				,     0  ).numpy()				,     expected.numpy()  )


				def 				__lowerCamelCase	(					self	:			int  )		->  str:







											"""simple docstring"""




											_lowerCAmelCase  	=			torch.tensor([1, 2, 3, 4, 23, 23, 23]  )
											_lowerCAmelCase  	=			torch.tensor([1, 1, 1, 1, 0, 0, 0]  )
											np.testing.assert_array_equal(build_mask(UpperCAmelCase_				,     23  ).numpy()				,     expected.numpy()  )


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







											"""simple docstring"""




											_lowerCAmelCase  	=			torch.tensor([8, 2, 3, 4, 1, 1, 1]  )
											_lowerCAmelCase  	=			torch.tensor([1, 1, 1, 1, 0, 0, 0]  )
											np.testing.assert_array_equal(build_mask(UpperCAmelCase_				,     1  ).numpy()				,     expected.numpy()  )







				def 				__lowerCamelCase	(					self	:			str  )		->  int:







											"""simple docstring"""




											_lowerCAmelCase  	=			101
											_lowerCAmelCase  	=			torch.tensor([[1, 2, 3, 4, 5, 6], [1, 2, 3, 101, 5, 6], [1, 101, 3, 4, 101, 6]]  )
											_lowerCAmelCase  	=			torch.tensor([[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1]]  )

											_lowerCAmelCase  	=			compute_token_type_ids(UpperCAmelCase_				,     UpperCAmelCase_  )
											np.testing.assert_array_equal(UpperCAmelCase_				,     UpperCAmelCase_  )






