"""simple docstring"""



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      _A	(						_UpperCAmelCase					):




    """simple docstring"""




    def __init__(		self							:     Union[str, Any]	,      A_							:     str	,      A_							:     Optional[Any]=13	,      A_							:     int=7	,      A_							:     Any=True	,      A_							:     List[Any]=True	,      A_							:     Any=True	,      A_							:     Dict=True	,      A_							:     Union[str, Any]=99	,      A_							:     Optional[Any]=32	,      A_							:     Dict=5	,      A_							:     List[Any]=4	,      A_							:     Optional[int]=37	,      A_							:     List[Any]="gelu"	,      A_							:     List[Any]=0.1	,      A_							:     Dict=0.1	,      A_							:     Optional[Any]=512	,      A_							:     List[Any]=16	,      A_							:     Union[str, Any]=2	,      A_							:     List[str]=0.02	,      A_							:     Tuple=False	,      A_							:     Optional[int]=True	,      A_							:     Union[str, Any]="None"	,      A_							:     Union[str, Any]=3	,      A_							:     Optional[Any]=4	,      A_							:     Optional[Any]=None	,      )    ->       int:
         __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  lowercase					(		self							:     int    )    ->       Dict:
         __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  lowercase					(		self							:     Union[str, Any]    )    ->       Optional[int]:
         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  lowercase					(		self							:     Optional[int]    )    ->       List[str]:
         __snake_case				=							self.get_config()
         __snake_case				=							300
         return config
    def  lowercase					(		self							:     str	,      A_							:     Union[str, Any]    )    ->       Optional[int]:
         self.parent.assertListEqual(list(result.loss.size()    )	,      []    )
    def  lowercase					(		self							:     Dict	,      A_							:     Optional[int]	,      A_							:     List[str]	,      A_							:     Any	,      A_							:     Union[str, Any]	,      A_							:     Dict	,      A_							:     Optional[Any]	,      A_							:     Union[str, Any]    )    ->       Tuple:
         __snake_case				=							DebertaModel(config=A_    )
         model.to(A_    )
         model.eval()
         __snake_case				=							model(A_	,      attention_mask=A_	,      token_type_ids=A_    )[0]
         __snake_case				=							model(A_	,      token_type_ids=A_    )[0]
         __snake_case				=							model(A_    )[0]

         self.parent.assertListEqual(list(sequence_output.size()    )	,      [self.batch_size, self.seq_length, self.hidden_size]    )
    def  lowercase					(		self							:     List[str]	,      A_							:     Optional[int]	,      A_							:     Optional[int]	,      A_							:     Optional[int]	,      A_							:     List[str]	,      A_							:     Dict	,      A_							:     int	,      A_							:     int    )    ->       Dict:
         __snake_case				=							DebertaForMaskedLM(config=A_    )
         model.to(A_    )
         model.eval()
         __snake_case				=							model(A_	,      attention_mask=A_	,      token_type_ids=A_	,      labels=A_    )

         self.parent.assertEqual(result.logits.shape	,      (self.batch_size, self.seq_length, self.vocab_size)    )
    def  lowercase					(		self							:     Tuple	,      A_							:     int	,      A_							:     str	,      A_							:     Optional[int]	,      A_							:     Any	,      A_							:     str	,      A_							:     Optional[Any]	,      A_							:     Dict    )    ->       Optional[Any]:
         __snake_case				=							self.num_labels
         __snake_case				=							DebertaForSequenceClassification(A_    )
         model.to(A_    )
         model.eval()
         __snake_case				=							model(A_	,      attention_mask=A_	,      token_type_ids=A_	,      labels=A_    )
         self.parent.assertListEqual(list(result.logits.size()    )	,      [self.batch_size, self.num_labels]    )
         self.check_loss_output(A_    )
    def  lowercase					(		self							:     Tuple	,      A_							:     str	,      A_							:     Optional[int]	,      A_							:     Optional[int]	,      A_							:     str	,      A_							:     List[str]	,      A_							:     Optional[int]	,      A_							:     Optional[Any]    )    ->       List[str]:
         __snake_case				=							self.num_labels
         __snake_case				=							DebertaForTokenClassification(config=A_    )
         model.to(A_    )
         model.eval()
         __snake_case				=							model(A_	,      attention_mask=A_	,      token_type_ids=A_	,      labels=A_    )
         self.parent.assertEqual(result.logits.shape	,      (self.batch_size, self.seq_length, self.num_labels)    )
    def  lowercase					(		self							:     List[Any]	,      A_							:     Union[str, Any]	,      A_							:     Dict	,      A_							:     str	,      A_							:     str	,      A_							:     Any	,      A_							:     str	,      A_							:     Tuple    )    ->       Dict:
         __snake_case				=							DebertaForQuestionAnswering(config=A_    )
         model.to(A_    )
         model.eval()
         __snake_case				=							model(
             A_	,      attention_mask=A_	,      token_type_ids=A_	,      start_positions=A_	,      end_positions=A_	,      )
         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  lowercase					(		self							:     List[Any]    )    ->       int:
         __snake_case				=							self.prepare_config_and_inputs()
         (
             (
             __snake_case	
         )		,	(
             __snake_case	
         )		,	(
             __snake_case	
         )		,	(
             __snake_case	
         )		,	(
             __snake_case	
         )		,	(
             __snake_case	
         )		,	(
             __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      _A	(						_UpperCAmelCase							, _UpperCAmelCase							, unittest.TestCase					):




    """simple docstring"""




    UpperCamelCase_	:					List[Any]							=					(
        (
            DebertaModel,
            DebertaForMaskedLM,
            DebertaForSequenceClassification,
            DebertaForTokenClassification,
            DebertaForQuestionAnswering,
        )
        if is_torch_available()
        else ()
    )
    UpperCamelCase_	:					Dict							=					(
        {
            '''feature-extraction''': DebertaModel,
            '''fill-mask''': DebertaForMaskedLM,
            '''question-answering''': DebertaForQuestionAnswering,
            '''text-classification''': DebertaForSequenceClassification,
            '''token-classification''': DebertaForTokenClassification,
            '''zero-shot''': DebertaForSequenceClassification,
        }
        if is_torch_available()
        else {}
    )

    UpperCamelCase_	:					str							=					True
    UpperCamelCase_	:					Optional[int]							=					False
    UpperCamelCase_	:					List[str]							=					False
    UpperCamelCase_	:					List[str]							=					False
    UpperCamelCase_	:					Optional[int]							=					False
    def  lowercase					(		self							:     Dict    )    ->       int:
         __snake_case				=							DebertaModelTester(self    )
         __snake_case				=							ConfigTester(self	,      config_class=A_	,      hidden_size=37    )
    def  lowercase					(		self							:     List[str]    )    ->       List[Any]:
         self.config_tester.run_common_tests()
    def  lowercase					(		self							:     Union[str, Any]    )    ->       int:
         __snake_case				=							self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_model(*A_    )
    def  lowercase					(		self							:     List[str]    )    ->       int:
         __snake_case				=							self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_sequence_classification(*A_    )
    def  lowercase					(		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(*A_    )
    def  lowercase					(		self							:     List[str]    )    ->       List[Any]:
         __snake_case				=							self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_question_answering(*A_    )
    def  lowercase					(		self							:     Dict    )    ->       Optional[Any]:
         __snake_case				=							self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_deberta_for_token_classification(*A_    )







    @slow
    def  lowercase					(		self							:     List[Any]    )    ->       Union[str, Any]:
         for model_name in DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
              __snake_case				=							DebertaModel.from_pretrained(A_    )
              self.assertIsNotNone(A_    )






@require_torch
@require_sentencepiece
@require_tokenizers
class      _A	(						unittest.TestCase					):




    """simple docstring"""




    @unittest.skip(reason='''Model not available yet'''    )
    def  lowercase					(		self							:     Tuple    )    ->       List[Any]:
         pass







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

         __snake_case				=							torch.tensor([[0, 31_414, 232, 328, 740, 1_140, 12_695, 69, 46_078, 1_588, 2]]    )
         __snake_case				=							torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]    )
         with torch.no_grad():
              __snake_case				=							model(A_	,      attention_mask=A_    )[0]
         # compare the actual values for a slice.
         __snake_case				=							torch.tensor(
             [[[-0.59_86, -0.80_55, -0.84_62], [1.44_84, -0.93_48, -0.80_59], [0.31_23, 0.00_32, -1.41_31]]]    )
         self.assertTrue(torch.allclose(output[:, 1:4, 1:4]	,      A_	,      atol=1E-4    )	,      f"{output[:, 1:4, 1:4]}"    )
"""simple docstring"""



import qiskit





def    SCREAMING_SNAKE_CASE       (     snake_case,      snake_case):
     __snake_case				=							qiskit.Aer.get_backend('''aer_simulator''')

     # Create a Quantum Circuit acting on the q register
     __snake_case				=							qiskit.QuantumCircuit(snake_case,      snake_case)

     # Map the quantum measurement to the classical bits
     circuit.measure([0],      [0])

     # Execute the circuit on the simulator
     __snake_case				=							qiskit.execute(snake_case,      snake_case,      shots=10_00)

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


if __name__ == "__main__":
       print(F"""Total count for various states are: {single_qubit_measure(1, 1)}""")