






'''simple docstring'''







import torch
from torch import nn
from transformers import CLIPPreTrainedModel, CLIPVisionModel

from ...models.attention import BasicTransformerBlock
from ...utils import logging


__lowerCAmelCase        =							logging.get_logger(__name__)  # pylint: disable=invalid-name




class   __SCREAMING_SNAKE_CASE       (__A       ):


  """simple docstring"""


  def __init__(			self   ,	UpperCamelCase__   ,	UpperCamelCase__=768	):






         """simple docstring"""


         super().__init__(UpperCamelCase__	)
         a_						     =			proj_size

         a_						     =			CLIPVisionModel(UpperCamelCase__	)
         a_						     =			PaintByExampleMapper(UpperCamelCase__	)
         a_						     =			nn.LayerNorm(config.hidden_size	)
         a_						     =			nn.Linear(config.hidden_size   ,	self.proj_size	)

         # uncondition for scaling
         a_						     =			nn.Parameter(torch.randn((1, 1, self.proj_size)	)	)







  def    _a       (			self   ,	UpperCamelCase__   ,	UpperCamelCase__=False	):






         """simple docstring"""


         a_						     =			self.model(pixel_values=UpperCamelCase__	)
         a_						     =			clip_output.pooler_output
         a_						     =			self.mapper(latent_states[:, None]	)
         a_						     =			self.final_layer_norm(UpperCamelCase__	)
         a_						     =			self.proj_out(UpperCamelCase__	)
         if return_uncond_vector:
                return latent_states, self.uncond_vector

         return latent_states





class   __SCREAMING_SNAKE_CASE       (nn.Module       ):


  """simple docstring"""


  def __init__(			self   ,	UpperCamelCase__	):






         """simple docstring"""


         super().__init__()
         a_						     =			(config.num_hidden_layers + 1) // 5
         a_						     =			config.hidden_size
         a_						     =			1
         a_						     =			nn.ModuleList(
             [
                 BasicTransformerBlock(UpperCamelCase__   ,	UpperCamelCase__   ,	UpperCamelCase__   ,	activation_fn='gelu'   ,	attention_bias=UpperCamelCase__	)
                 for _ in range(UpperCamelCase__	)
             ]	)







  def    _a       (			self   ,	UpperCamelCase__	):






         """simple docstring"""


         for block in self.blocks:
                a_						     =			block(UpperCamelCase__	)

         return hidden_states












'''simple docstring'''







import math

import qiskit


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

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

       a_						     =			qiskit.Aer.get_backend('aer_simulator'   )
       a_						     =			qiskit.execute(lowercase_   ,       lowercase_   ,       shots=1_000   )

       return job.result().get_counts(lowercase_   )


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




