


'''simple docstring'''



import math

import qiskit




def      _a     (						_lowercase :     int = 1      , _lowercase :     int = 1      , _lowercase :     int = 1  ):





     '''simple docstring'''






     if (
         isinstance(_lowercase      , _lowercase  )
         or isinstance(_lowercase      , _lowercase  )
         or isinstance(_lowercase      , _lowercase  )
     ):
          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(_lowercase  ) != input_a)
         or (math.floor(_lowercase  ) != input_a)
         or (math.floor(_lowercase  ) != 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     :			str  							=      qiskit.QuantumRegister(4      , '''qr'''  )
     __UpperCAmelCase     :			str  							=      qiskit.ClassicalRegister(2      , '''cr'''  )
     # list the entries
     __UpperCAmelCase     :			Union[str, Any]  							=      [input_a, input_a, carry_in]

     __UpperCAmelCase     :			Dict  							=      qiskit.QuantumCircuit(_lowercase      , _lowercase  )

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

     __UpperCAmelCase     :			Tuple  							=      qiskit.Aer.get_backend('''aer_simulator'''  )
     __UpperCAmelCase     :			Optional[Any]  							=      qiskit.execute(_lowercase      , _lowercase      , shots=1000  )

     return job.result().get_counts(_lowercase  )


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



'''simple docstring'''



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__UpperCAmelCase      :List[Any]			    =       {
    "configuration_lxmert": ["LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "LxmertConfig"],
    "tokenization_lxmert": ["LxmertTokenizer"],
}

try:
      if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      __UpperCAmelCase      :List[Any]			    =       ["LxmertTokenizerFast"]

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      __UpperCAmelCase      :List[Any]			    =       [
          "LxmertEncoder",
          "LxmertForPreTraining",
          "LxmertForQuestionAnswering",
          "LxmertModel",
          "LxmertPreTrainedModel",
          "LxmertVisualFeatureEncoder",
          "LxmertXLayer",
      ]

try:
      if not is_tf_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      __UpperCAmelCase      :List[str]			    =       [
          "TF_LXMERT_PRETRAINED_MODEL_ARCHIVE_LIST",
          "TFLxmertForPreTraining",
          "TFLxmertMainLayer",
          "TFLxmertModel",
          "TFLxmertPreTrainedModel",
          "TFLxmertVisualFeatureEncoder",
      ]


if TYPE_CHECKING:
      from .configuration_lxmert import LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP, LxmertConfig
      from .tokenization_lxmert import LxmertTokenizer

      try:
            if not is_tokenizers_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .tokenization_lxmert_fast import LxmertTokenizerFast

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_lxmert import (
                LxmertEncoder,
                LxmertForPreTraining,
                LxmertForQuestionAnswering,
                LxmertModel,
                LxmertPreTrainedModel,
                LxmertVisualFeatureEncoder,
                LxmertXLayer,
            )

      try:
            if not is_tf_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_tf_lxmert import (
                TF_LXMERT_PRETRAINED_MODEL_ARCHIVE_LIST,
                TFLxmertForPreTraining,
                TFLxmertMainLayer,
                TFLxmertModel,
                TFLxmertPreTrainedModel,
                TFLxmertVisualFeatureEncoder,
            )

else:
      import sys

      __UpperCAmelCase      :int			    =       _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)