






import unittest

from transformers import DebertaConfig, is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
							import torch

							from transformers import (
							    DebertaForMaskedLM,
							    DebertaForQuestionAnswering,
							    DebertaForSequenceClassification,
							    DebertaForTokenClassification,
							    DebertaModel,
							)
							from transformers.models.deberta.modeling_deberta import DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST


class   __SCREAMING_SNAKE_CASE(	a_	):
							def __init__(     self:      List[Any]       ,	UpperCamelCase:      Optional[int]       ,	UpperCamelCase:      Union[str, Any]=13       ,	UpperCamelCase:      List[Any]=7       ,	UpperCamelCase:      Optional[int]=True       ,	UpperCamelCase:      Dict=True       ,	UpperCamelCase:      int=True       ,	UpperCamelCase:      Tuple=True       ,	UpperCamelCase:      Any=99       ,	UpperCamelCase:      Tuple=32       ,	UpperCamelCase:      List[str]=5       ,	UpperCamelCase:      Dict=4       ,	UpperCamelCase:      Dict=37       ,	UpperCamelCase:      Union[str, Any]="gelu"       ,	UpperCamelCase:      Union[str, Any]=0.1       ,	UpperCamelCase:      Tuple=0.1       ,	UpperCamelCase:      Optional[Any]=5_12       ,	UpperCamelCase:      Optional[Any]=16       ,	UpperCamelCase:      Tuple=2       ,	UpperCamelCase:      List[Any]=0.02       ,	UpperCamelCase:      Optional[int]=False       ,	UpperCamelCase:      int=True       ,	UpperCamelCase:      Union[str, Any]="None"       ,	UpperCamelCase:      List[Any]=3       ,	UpperCamelCase:      int=4       ,	UpperCamelCase:      List[str]=None       ,	)		->		Union[str, Any]:
											snake_case__									=     parent
											snake_case__									=     batch_size
											snake_case__									=     seq_length
											snake_case__									=     is_training
											snake_case__									=     use_input_mask
											snake_case__									=     use_token_type_ids
											snake_case__									=     use_labels
											snake_case__									=     vocab_size
											snake_case__									=     hidden_size
											snake_case__									=     num_hidden_layers
											snake_case__									=     num_attention_heads
											snake_case__									=     intermediate_size
											snake_case__									=     hidden_act
											snake_case__									=     hidden_dropout_prob
											snake_case__									=     attention_probs_dropout_prob
											snake_case__									=     max_position_embeddings
											snake_case__									=     type_vocab_size
											snake_case__									=     type_sequence_label_size
											snake_case__									=     initializer_range
											snake_case__									=     num_labels
											snake_case__									=     num_choices
											snake_case__									=     relative_attention
											snake_case__									=     position_biased_input
											snake_case__									=     pos_att_type
											snake_case__									=     scope
							def lowerCAmelCase_ (     self:      int						)		->		List[str]:
											snake_case__									=     ids_tensor([self.batch_size, self.seq_length]       ,	self.vocab_size						)

											snake_case__									=     None
											if self.use_input_mask:
															snake_case__									=     ids_tensor([self.batch_size, self.seq_length]       ,	vocab_size=2						)

											snake_case__									=     None
											if self.use_token_type_ids:
															snake_case__									=     ids_tensor([self.batch_size, self.seq_length]       ,	self.type_vocab_size						)

											snake_case__									=     None
											snake_case__									=     None
											snake_case__									=     None
											if self.use_labels:
															snake_case__									=     ids_tensor([self.batch_size]       ,	self.type_sequence_label_size						)
															snake_case__									=     ids_tensor([self.batch_size, self.seq_length]       ,	self.num_labels						)
															snake_case__									=     ids_tensor([self.batch_size]       ,	self.num_choices						)

											snake_case__									=     self.get_config()

											return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels
							def lowerCAmelCase_ (     self:      List[Any]						)		->		Any:
											return DebertaConfig(
											    vocab_size=self.vocab_size       ,	hidden_size=self.hidden_size       ,	num_hidden_layers=self.num_hidden_layers       ,	num_attention_heads=self.num_attention_heads       ,	intermediate_size=self.intermediate_size       ,	hidden_act=self.hidden_act       ,	hidden_dropout_prob=self.hidden_dropout_prob       ,	attention_probs_dropout_prob=self.attention_probs_dropout_prob       ,	max_position_embeddings=self.max_position_embeddings       ,	type_vocab_size=self.type_vocab_size       ,	initializer_range=self.initializer_range       ,	relative_attention=self.relative_attention       ,	position_biased_input=self.position_biased_input       ,	pos_att_type=self.pos_att_type       ,	)
							def lowerCAmelCase_ (     self:      str						)		->		Dict:
											snake_case__									=     self.get_config()
											snake_case__									=     3_00
											return config
							def lowerCAmelCase_ (     self:      str       ,	UpperCamelCase:      Tuple						)		->		str:
											self.parent.assertListEqual(list(result.loss.size()						)       ,	[]						)
							def lowerCAmelCase_ (     self:      List[str]       ,	UpperCamelCase:      Optional[Any]       ,	UpperCamelCase:      str       ,	UpperCamelCase:      int       ,	UpperCamelCase:      Tuple       ,	UpperCamelCase:      Any       ,	UpperCamelCase:      Tuple       ,	UpperCamelCase:      List[Any]						)		->		Optional[int]:
											snake_case__									=     DebertaModel(config=UpperCamelCase						)
											model.to(UpperCamelCase						)
											model.eval()
											snake_case__									=     model(UpperCamelCase       ,	attention_mask=UpperCamelCase       ,	token_type_ids=UpperCamelCase						)[0]
											snake_case__									=     model(UpperCamelCase       ,	token_type_ids=UpperCamelCase						)[0]
											snake_case__									=     model(UpperCamelCase						)[0]

											self.parent.assertListEqual(list(sequence_output.size()						)       ,	[self.batch_size, self.seq_length, self.hidden_size]						)
							def lowerCAmelCase_ (     self:      str       ,	UpperCamelCase:      Dict       ,	UpperCamelCase:      int       ,	UpperCamelCase:      List[str]       ,	UpperCamelCase:      Tuple       ,	UpperCamelCase:      str       ,	UpperCamelCase:      Union[str, Any]       ,	UpperCamelCase:      Dict						)		->		Optional[int]:
											snake_case__									=     DebertaForMaskedLM(config=UpperCamelCase						)
											model.to(UpperCamelCase						)
											model.eval()
											snake_case__									=     model(UpperCamelCase       ,	attention_mask=UpperCamelCase       ,	token_type_ids=UpperCamelCase       ,	labels=UpperCamelCase						)

											self.parent.assertEqual(result.logits.shape       ,	(self.batch_size, self.seq_length, self.vocab_size)						)
							def lowerCAmelCase_ (     self:      List[Any]       ,	UpperCamelCase:      Optional[Any]       ,	UpperCamelCase:      List[str]       ,	UpperCamelCase:      Tuple       ,	UpperCamelCase:      List[str]       ,	UpperCamelCase:      Any       ,	UpperCamelCase:      Any       ,	UpperCamelCase:      Any						)		->		Optional[Any]:
											snake_case__									=     self.num_labels
											snake_case__									=     DebertaForSequenceClassification(UpperCamelCase						)
											model.to(UpperCamelCase						)
											model.eval()
											snake_case__									=     model(UpperCamelCase       ,	attention_mask=UpperCamelCase       ,	token_type_ids=UpperCamelCase       ,	labels=UpperCamelCase						)
											self.parent.assertListEqual(list(result.logits.size()						)       ,	[self.batch_size, self.num_labels]						)
											self.check_loss_output(UpperCamelCase						)
							def lowerCAmelCase_ (     self:      Union[str, Any]       ,	UpperCamelCase:      Optional[Any]       ,	UpperCamelCase:      Any       ,	UpperCamelCase:      List[Any]       ,	UpperCamelCase:      Any       ,	UpperCamelCase:      Union[str, Any]       ,	UpperCamelCase:      str       ,	UpperCamelCase:      int						)		->		Optional[int]:
											snake_case__									=     self.num_labels
											snake_case__									=     DebertaForTokenClassification(config=UpperCamelCase						)
											model.to(UpperCamelCase						)
											model.eval()
											snake_case__									=     model(UpperCamelCase       ,	attention_mask=UpperCamelCase       ,	token_type_ids=UpperCamelCase       ,	labels=UpperCamelCase						)
											self.parent.assertEqual(result.logits.shape       ,	(self.batch_size, self.seq_length, self.num_labels)						)
							def lowerCAmelCase_ (     self:      List[str]       ,	UpperCamelCase:      List[Any]       ,	UpperCamelCase:      List[str]       ,	UpperCamelCase:      Dict       ,	UpperCamelCase:      Tuple       ,	UpperCamelCase:      Optional[int]       ,	UpperCamelCase:      List[Any]       ,	UpperCamelCase:      Union[str, Any]						)		->		int:
											snake_case__									=     DebertaForQuestionAnswering(config=UpperCamelCase						)
											model.to(UpperCamelCase						)
											model.eval()
											snake_case__									=     model(
											    UpperCamelCase       ,	attention_mask=UpperCamelCase       ,	token_type_ids=UpperCamelCase       ,	start_positions=UpperCamelCase       ,	end_positions=UpperCamelCase       ,	)
											self.parent.assertEqual(result.start_logits.shape       ,	(self.batch_size, self.seq_length)						)
											self.parent.assertEqual(result.end_logits.shape       ,	(self.batch_size, self.seq_length)						)


							def lowerCAmelCase_ (     self:      str						)		->		Any:
											snake_case__									=     self.prepare_config_and_inputs()
											(
											    snake_case__       
											)									=     config_and_inputs
											snake_case__									=     {'input_ids': input_ids, 'token_type_ids': token_type_ids, 'attention_mask': input_mask}
											return config, inputs_dict


@require_torch
class   __SCREAMING_SNAKE_CASE(	a_    ,  a_    ,  unittest.TestCase	):
							_UpperCAmelCase     =       (
							    (
							        DebertaModel,
							        DebertaForMaskedLM,
							        DebertaForSequenceClassification,
							        DebertaForTokenClassification,
							        DebertaForQuestionAnswering,
							    )
							    if is_torch_available()
							    else ()
							)
							_UpperCAmelCase     =       (
							    {
							        "feature-extraction": DebertaModel,
							        "fill-mask": DebertaForMaskedLM,
							        "question-answering": DebertaForQuestionAnswering,
							        "text-classification": DebertaForSequenceClassification,
							        "token-classification": DebertaForTokenClassification,
							        "zero-shot": DebertaForSequenceClassification,
							    }
							    if is_torch_available()
							    else {}
							)

							_UpperCAmelCase     =       True
							_UpperCAmelCase     =       False
							_UpperCAmelCase     =       False
							_UpperCAmelCase     =       False
							_UpperCAmelCase     =       False
							def lowerCAmelCase_ (     self:      str						)		->		List[str]:
											snake_case__									=     DebertaModelTester(self						)
											snake_case__									=     ConfigTester(self       ,	config_class=UpperCamelCase       ,	hidden_size=37						)
							def lowerCAmelCase_ (     self:      str						)		->		List[Any]:
											self.config_tester.run_common_tests()
							def lowerCAmelCase_ (     self:      Optional[int]						)		->		Optional[int]:
											snake_case__									=     self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_deberta_model(*UpperCamelCase						)
							def lowerCAmelCase_ (     self:      Tuple						)		->		int:
											snake_case__									=     self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_deberta_for_sequence_classification(*UpperCamelCase						)
							def lowerCAmelCase_ (     self:      Union[str, Any]						)		->		List[Any]:
											snake_case__									=     self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_deberta_for_masked_lm(*UpperCamelCase						)
							def lowerCAmelCase_ (     self:      Optional[int]						)		->		List[Any]:
											snake_case__									=     self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_deberta_for_question_answering(*UpperCamelCase						)
							def lowerCAmelCase_ (     self:      List[str]						)		->		Optional[int]:
											snake_case__									=     self.model_tester.prepare_config_and_inputs()
											self.model_tester.create_and_check_deberta_for_token_classification(*UpperCamelCase						)


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







											for model_name in DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															snake_case__									=     DebertaModel.from_pretrained(UpperCamelCase						)
															self.assertIsNotNone(UpperCamelCase						)


@require_torch
@require_sentencepiece
@require_tokenizers
class   __SCREAMING_SNAKE_CASE(	unittest.TestCase	):
							@unittest.skip(reason='Model not available yet'						)
							def lowerCAmelCase_ (     self:      Union[str, Any]						)		->		Optional[Any]:
											pass


							@slow
							def lowerCAmelCase_ (     self:      Optional[Any]						)		->		List[Any]:
											snake_case__									=     DebertaModel.from_pretrained('microsoft/deberta-base'						)

											snake_case__									=     torch.tensor([[0, 3_14_14, 2_32, 3_28, 7_40, 11_40, 1_26_95, 69, 4_60_78, 15_88, 2]]						)
											snake_case__									=     torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]						)
											with torch.no_grad():
															snake_case__									=     model(UpperCamelCase       ,	attention_mask=UpperCamelCase						)[0]
											# compare the actual values for a slice.
											snake_case__									=     torch.tensor(
											    [[[-0.5_986, -0.8_055, -0.8_462], [1.4_484, -0.9_348, -0.8_059], [0.3_123, 0.0_032, -1.4_131]]]						)
											self.assertTrue(torch.allclose(output[:, 1:4, 1:4]       ,	UpperCamelCase       ,	atol=1e-4						)       ,	F'''{output[:, 1:4, 1:4]}'''						)












import qiskit
def      a_ (      _A = 2  )			->			qiskit.result.counts.Counts:







				"""simple docstring"""
				snake_case__									=     qubits

				# Using Aer's simulator
				snake_case__									=     qiskit.Aer.get_backend('aer_simulator'  )

				# Creating a Quantum Circuit acting on the q register
				snake_case__									=     qiskit.QuantumCircuit(_A      ,   _A  )

				# Adding a H gate on qubit 0 (now q0 in superposition)
				circuit.h(0  )

				for i in range(1      ,   _A  ):
								# Adding CX (CNOT) gate
								circuit.cx(i - 1      ,   _A  )

				# Mapping the quantum measurement to the classical bits
				circuit.measure(list(range(_A  )  )      ,   list(range(_A  )  )  )

				# Now measuring any one qubit would affect other qubits to collapse
				# their super position and have same state as the measured one.

				# Executing the circuit on the simulator
				snake_case__									=     qiskit.execute(_A      ,   _A      ,   shots=1000  )

				return job.result().get_counts(_A  )


if __name__ == "__main__":
							print(f'''Total count for various states are: {quantum_entanglement(3)}''')




