






import unittest

from transformers.utils.backbone_utils import (
    BackboneMixin,
    get_aligned_output_features_output_indices,
    verify_out_features_out_indices,
)






class 			_UpperCamelCase(       unittest.TestCase		):

		def    __lowerCAmelCase  (					self		:    Tuple    ):



					'''simple docstring'''



					__a						:  Union[str, Any]									=     ['a', 'b', 'c']

					# Defaults to last layer if both are None
					__a						,					__a						:  Tuple									=     get_aligned_output_features_output_indices(SCREAMING_SNAKE_CASE__    ,       SCREAMING_SNAKE_CASE__    ,       SCREAMING_SNAKE_CASE__    )
					self.assertEqual(SCREAMING_SNAKE_CASE__    ,       ['c']    )
					self.assertEqual(SCREAMING_SNAKE_CASE__    ,       [2]    )

					# Out indices set to match out features
					__a						,					__a						:  Optional[int]									=     get_aligned_output_features_output_indices(['a', 'c']    ,       SCREAMING_SNAKE_CASE__    ,       SCREAMING_SNAKE_CASE__    )
					self.assertEqual(SCREAMING_SNAKE_CASE__    ,       ['a', 'c']    )
					self.assertEqual(SCREAMING_SNAKE_CASE__    ,       [0, 2]    )

					# Out features set to match out indices
					__a						,					__a						:  Any									=     get_aligned_output_features_output_indices(SCREAMING_SNAKE_CASE__    ,       [0, 2]    ,       SCREAMING_SNAKE_CASE__    )
					self.assertEqual(SCREAMING_SNAKE_CASE__    ,       ['a', 'c']    )
					self.assertEqual(SCREAMING_SNAKE_CASE__    ,       [0, 2]    )

					# Out features selected from negative indices
					__a						,					__a						:  List[str]									=     get_aligned_output_features_output_indices(SCREAMING_SNAKE_CASE__    ,       [-3, -1]    ,       SCREAMING_SNAKE_CASE__    )
					self.assertEqual(SCREAMING_SNAKE_CASE__    ,       ['a', 'c']    )
					self.assertEqual(SCREAMING_SNAKE_CASE__    ,       [-3, -1]    )

		def    __lowerCAmelCase  (					self		:    int    ):



					'''simple docstring'''



					with self.assertRaises(SCREAMING_SNAKE_CASE__    ):
								verify_out_features_out_indices(['a', 'b']    ,       (0, 1)    ,       SCREAMING_SNAKE_CASE__    )

					# Out features must be a list
					with self.assertRaises(SCREAMING_SNAKE_CASE__    ):
								verify_out_features_out_indices(('a', 'b')    ,       (0, 1)    ,       ['a', 'b']    )

					# Out features must be a subset of stage names
					with self.assertRaises(SCREAMING_SNAKE_CASE__    ):
								verify_out_features_out_indices(['a', 'b']    ,       (0, 1)    ,       ['a']    )

					# Out indices must be a list or tuple
					with self.assertRaises(SCREAMING_SNAKE_CASE__    ):
								verify_out_features_out_indices(SCREAMING_SNAKE_CASE__    ,       0    ,       ['a', 'b']    )

					# Out indices must be a subset of stage names
					with self.assertRaises(SCREAMING_SNAKE_CASE__    ):
								verify_out_features_out_indices(SCREAMING_SNAKE_CASE__    ,       (0, 1)    ,       ['a']    )

					# Out features and out indices must be the same length
					with self.assertRaises(SCREAMING_SNAKE_CASE__    ):
								verify_out_features_out_indices(['a', 'b']    ,       (0,)    ,       ['a', 'b', 'c']    )

					# Out features should match out indices
					with self.assertRaises(SCREAMING_SNAKE_CASE__    ):
								verify_out_features_out_indices(['a', 'b']    ,       (0, 2)    ,       ['a', 'b', 'c']    )

					# Out features and out indices should be in order
					with self.assertRaises(SCREAMING_SNAKE_CASE__    ):
								verify_out_features_out_indices(['b', 'a']    ,       (0, 1)    ,       ['a', 'b']    )

					# Check passes with valid inputs
					verify_out_features_out_indices(['a', 'b', 'd']    ,       (0, 1, -1)    ,       ['a', 'b', 'c', 'd']    )



		def    __lowerCAmelCase  (					self		:    Union[str, Any]    ):



					'''simple docstring'''



					__a						:  List[str]									=     BackboneMixin()

					__a						:  List[Any]									=     ['a', 'b', 'c']
					__a						:  List[str]									=     ['a', 'c']
					__a						:  List[Any]									=     [0, 2]

					# Check that the output features and indices are set correctly
					self.assertEqual(backbone.out_features    ,       ['a', 'c']    )
					self.assertEqual(backbone.out_indices    ,       [0, 2]    )

					# Check out features and indices are updated correctly
					__a						:  Optional[int]									=     ['a', 'b']
					self.assertEqual(backbone.out_features    ,       ['a', 'b']    )
					self.assertEqual(backbone.out_indices    ,       [0, 1]    )

					__a						:  Dict									=     [-3, -1]
					self.assertEqual(backbone.out_features    ,       ['a', 'c']    )
					self.assertEqual(backbone.out_indices    ,       [-3, -1]    )









'''simple docstring'''
import math

import qiskit

def 					lowerCamelCase_ ( __UpperCamelCase					:       int = 1							,    __UpperCamelCase					:       int = 1							,    __UpperCamelCase					:       int = 1		)					->	qiskit.result.counts.Counts:







     """simple docstring"""
     if (
         isinstance(__UpperCamelCase							,    __UpperCamelCase		)
         or isinstance(__UpperCamelCase							,    __UpperCamelCase		)
         or isinstance(__UpperCamelCase							,    __UpperCamelCase		)
     ):
          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(__UpperCamelCase		) != input_a)
         or (math.floor(__UpperCamelCase		) != input_a)
         or (math.floor(__UpperCamelCase		) != 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
     _A				=							qiskit.QuantumRegister(4							,    'qr'		)
     _A				=							qiskit.ClassicalRegister(2							,    'cr'		)
     # list the entries
     _A				=							[input_a, input_a, carry_in]

     _A				=							qiskit.QuantumCircuit(__UpperCamelCase							,    __UpperCamelCase		)

     for i in range(0							,    3		):
          if entry[i] == 2:
               quantum_circuit.h(__UpperCamelCase		)  # for hadamard entries
          elif entry[i] == 1:
               quantum_circuit.x(__UpperCamelCase		)  # for 1 entries
          elif entry[i] == 0:
               quantum_circuit.i(__UpperCamelCase		)  # 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]							,    __UpperCamelCase		)  # measure the last two qbits

     _A				=							qiskit.Aer.get_backend('aer_simulator'		)
     _A				=							qiskit.execute(__UpperCamelCase							,    __UpperCamelCase							,    shots=1_0_0_0		)

     return job.result().get_counts(__UpperCamelCase		)


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





