


import importlib
import os
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, Optional, Union

import torch

from ..utils import BaseOutput


__a     =			"scheduler_config.json"






class   __lowercase				(  _UpperCAmelCase  ):
      UpperCamelCase								=       1
      UpperCamelCase								=       2
      UpperCamelCase								=       3
      UpperCamelCase								=       4
      UpperCamelCase								=       5
      UpperCamelCase								=       6
      UpperCamelCase								=       7
      UpperCamelCase								=       8
      UpperCamelCase								=       9
      UpperCamelCase								=       10
      UpperCamelCase								=       11
      UpperCamelCase								=       12
      UpperCamelCase								=       13
      UpperCamelCase								=       14






@dataclass
class   __lowercase				(  _UpperCAmelCase  ):
      UpperCamelCase								=       42






class   __lowercase				:
      UpperCamelCase								=       SCHEDULER_CONFIG_NAME
      UpperCamelCase								=       []
      UpperCamelCase								=       True





      @classmethod
      def        _lowercase				(		cls						:					Optional[Any]					,       __lowerCamelCase						:					Dict[str, Any] = None					,       __lowerCamelCase						:					Optional[str] = None					,       __lowerCamelCase						:					Optional[int]=False					,       **__lowerCamelCase						:					int					,       )    ->   List[str]:






         """simple docstring"""







         UpperCAmelCase							=     cls.load_config(
             pretrained_model_name_or_path=lowercase_					,       subfolder=lowercase_					,       return_unused_kwargs=lowercase_					,       return_commit_hash=lowercase_					,       **lowercase_					,       )
         return cls.from_config(lowercase_					,       return_unused_kwargs=lowercase_					,       **lowercase_       )





      def        _lowercase				(		self						:					List[str]					,       __lowerCamelCase						:					Union[str, os.PathLike]					,       __lowerCamelCase						:					bool = False					,       **__lowerCamelCase						:					str       )    ->   List[str]:






         """simple docstring"""







         self.save_config(save_directory=lowercase_					,       push_to_hub=lowercase_					,       **lowercase_       )





      @property
      def        _lowercase				(		self						:					Dict       )    ->   List[str]:






         """simple docstring"""







         return self._get_compatibles()





      @classmethod
      def        _lowercase				(		cls						:					int       )    ->   Tuple:






         """simple docstring"""







         UpperCAmelCase							=     list(set([cls.__name__] + cls._compatibles       )       )
         UpperCAmelCase							=     importlib.import_module(__name__.split("""."""       )[0]       )
         UpperCAmelCase							=     [
             getattr(lowercase_					,       lowercase_       ) for c in compatible_classes_str if hasattr(lowercase_					,       lowercase_       )
         ]
         return compatible_classes







import math

import qiskit
def   _UpperCamelCase				(						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
   UpperCAmelCase							=     qiskit.QuantumRegister(4  ,						"""qr"""   )
   UpperCAmelCase							=     qiskit.ClassicalRegister(2  ,						"""cr"""   )
   # list the entries
   UpperCAmelCase							=     [input_a, input_a, carry_in]

   UpperCAmelCase							=     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

   UpperCAmelCase							=     qiskit.Aer.get_backend("""aer_simulator"""   )
   UpperCAmelCase							=     qiskit.execute(lowerCAmelCase_  ,						lowerCAmelCase_  ,						shots=1_0_0_0   )

   return job.result().get_counts(lowerCAmelCase_   )


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



