


from dataclasses import dataclass
from typing import Optional, Tuple

import torch
from torch import nn
from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel
from transformers.utils import ModelOutput







@dataclass
class 				snake_case__(							UpperCAmelCase__							):







						'''simple docstring'''




						SCREAMING_SNAKE_CASE__      :  Optional[torch.FloatTensor]					=							None
						SCREAMING_SNAKE_CASE__      :  torch.FloatTensor					=							None
						SCREAMING_SNAKE_CASE__      :  Optional[Tuple[torch.FloatTensor]]					=							None
						SCREAMING_SNAKE_CASE__      :  Optional[Tuple[torch.FloatTensor]]					=							None







class 				snake_case__(							UpperCAmelCase__							):







						'''simple docstring'''




						def __init__(				self   ,						__lowercase=1   ,						__lowercase=0   ,						__lowercase=2   ,						__lowercase=5_1_2   ,						__lowercase="cls"   ,						__lowercase=False   ,						__lowercase=True   ,						**__lowercase   ,						)					->    List[Any]:
										super().__init__(pad_token_id=__lowercase   ,						bos_token_id=__lowercase   ,						eos_token_id=__lowercase   ,						**__lowercase							)
										lowerCAmelCase_ :      Any    				=				project_dim
										lowerCAmelCase_ :      Union[str, Any]    				=				pooler_fn
										lowerCAmelCase_ :      List[str]    				=				learn_encoder
										lowerCAmelCase_ :      int    				=				use_attention_mask







class 				snake_case__(							UpperCAmelCase__							):







						'''simple docstring'''




						SCREAMING_SNAKE_CASE__      :  Union[str, Any]					=							[r"""pooler""", r"""logit_scale"""]
						SCREAMING_SNAKE_CASE__      :  Any					=							[r"""position_ids""", r"""predictions.decoder.bias"""]
						SCREAMING_SNAKE_CASE__      :  Any					=							"""roberta"""
						SCREAMING_SNAKE_CASE__      :  str					=							RobertaSeriesConfig




						def __init__(				self   ,						__lowercase							)					->    Tuple:
										super().__init__(__lowercase							)
										lowerCAmelCase_ :      Dict    				=				XLMRobertaModel(__lowercase							)
										lowerCAmelCase_ :      Optional[int]    				=				nn.Linear(config.hidden_size   ,						config.project_dim							)
										lowerCAmelCase_ :      Optional[Any]    				=				getattr(__lowercase   ,						'''has_pre_transformation'''   ,						__lowercase							)
										if self.has_pre_transformation:
														lowerCAmelCase_ :      int    				=				nn.Linear(config.hidden_size   ,						config.project_dim							)
														lowerCAmelCase_ :      Optional[int]    				=				nn.LayerNorm(config.hidden_size   ,						eps=config.layer_norm_eps							)
										self.post_init()




						def 						lowercase_ (				self   ,						__lowercase = None   ,						__lowercase = None   ,						__lowercase = None   ,						__lowercase = None   ,						__lowercase = None   ,						__lowercase = None   ,						__lowercase = None   ,						__lowercase = None   ,						__lowercase = None   ,						__lowercase = None   ,						__lowercase = None   ,						)					->    int:
										lowerCAmelCase_ :      Optional[int]    				=				return_dict if return_dict is not None else self.config.use_return_dict

										lowerCAmelCase_ :      int    				=				self.base_model(
										    input_ids=__lowercase   ,						attention_mask=__lowercase   ,						token_type_ids=__lowercase   ,						position_ids=__lowercase   ,						head_mask=__lowercase   ,						inputs_embeds=__lowercase   ,						encoder_hidden_states=__lowercase   ,						encoder_attention_mask=__lowercase   ,						output_attentions=__lowercase   ,						output_hidden_states=True if self.has_pre_transformation else output_hidden_states   ,						return_dict=__lowercase   ,						)

										if self.has_pre_transformation:
														lowerCAmelCase_ :      Dict    				=				outputs['''hidden_states'''][-2]
														lowerCAmelCase_ :      Tuple    				=				self.pre_LN(__lowercase							)
														lowerCAmelCase_ :      int    				=				self.transformation_pre(__lowercase							)

														return TransformationModelOutput(
														    projection_state=__lowercase   ,						last_hidden_state=outputs.last_hidden_state   ,						hidden_states=outputs.hidden_states   ,						attentions=outputs.attentions   ,						)
										else:
														lowerCAmelCase_ :      Optional[int]    				=				self.transformation(outputs.last_hidden_state							)
														return TransformationModelOutput(
														    projection_state=__lowercase   ,						last_hidden_state=outputs.last_hidden_state   ,						hidden_states=outputs.hidden_states   ,						attentions=outputs.attentions   ,						)



import math

import qiskit



def 			lowerCAmelCase (		lowerCAmelCase_ = 1 ,   lowerCAmelCase_ = 1 ,   lowerCAmelCase_ = 1 )-> qiskit.result.counts.Counts:
				if (
				    isinstance(lowerCAmelCase_ ,   lowerCAmelCase_ )
				    or isinstance(lowerCAmelCase_ ,   lowerCAmelCase_ )
				    or isinstance(lowerCAmelCase_ ,   lowerCAmelCase_ )
				):
								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(lowerCAmelCase_ ) != input_a)
				    or (math.floor(lowerCAmelCase_ ) != input_a)
				    or (math.floor(lowerCAmelCase_ ) != 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_ :      str    				=				qiskit.QuantumRegister(4 ,   '''qr''' )
				lowerCAmelCase_ :      str    				=				qiskit.ClassicalRegister(2 ,   '''cr''' )
				# list the entries
				lowerCAmelCase_ :      Any    				=				[input_a, input_a, carry_in]

				lowerCAmelCase_ :      int    				=				qiskit.QuantumCircuit(lowerCAmelCase_ ,   lowerCAmelCase_ )

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

				lowerCAmelCase_ :      Tuple    				=				qiskit.Aer.get_backend('''aer_simulator''' )
				lowerCAmelCase_ :      Union[str, Any]    				=				qiskit.execute(lowerCAmelCase_ ,   lowerCAmelCase_ ,   shots=1_000 )

				return job.result().get_counts(lowerCAmelCase_ )


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