


from typing import Optional

from torch import nn

from .transformer_ad import TransformeraDModel, TransformeraDModelOutput







class 							lowerCamelCase__						(				nn.Module   ):






			"""simple docstring"""






			def __init__(				self   ,    snake_case = 16   ,    snake_case = 88   ,    snake_case = None   ,    snake_case = 1   ,    snake_case = 0.0   ,    snake_case = 32   ,    snake_case = None   ,    snake_case = False   ,    snake_case = None   ,    snake_case = None   ,    snake_case = "geglu"   ,    snake_case = None   ,    ):

						'''simple docstring'''


						super().__init__()
						UpperCamelCase__       =							nn.ModuleList(
						    [
						        TransformeraDModel(
						            num_attention_heads=a_   ,    attention_head_dim=a_   ,    in_channels=a_   ,    num_layers=a_   ,    dropout=a_   ,    norm_num_groups=a_   ,    cross_attention_dim=a_   ,    attention_bias=a_   ,    sample_size=a_   ,    num_vector_embeds=a_   ,    activation_fn=a_   ,    num_embeds_ada_norm=a_   ,    )
						        for _ in range(2  )
						    ]  )

						# Variables that can be set by a pipeline:

						# The ratio of transformer1 to transformer2's output states to be combined during inference
						UpperCamelCase__       =							0.5

						# The shape of `encoder_hidden_states` is expected to be
						# `(batch_size, condition_lengths[0]+condition_lengths[1], num_features)`
						UpperCamelCase__       =							[77, 257]

						# Which transformer to use to encode which condition.
						# E.g. `(1, 0)` means that we'll use `transformers[1](conditions[0])` and `transformers[0](conditions[1])`
						UpperCamelCase__       =							[1, 0]







			def 					snake_case__					(				self   ,    snake_case   ,    snake_case   ,    snake_case=None   ,    snake_case=None   ,    snake_case=None   ,    snake_case = True   ,    ):

						'''simple docstring'''


						UpperCamelCase__       =							hidden_states

						UpperCamelCase__       =							[]
						UpperCamelCase__       =							0
						# attention_mask is not used yet
						for i in range(2  ):
									# for each of the two transformers, pass the corresponding condition tokens
									UpperCamelCase__       =							encoder_hidden_states[:, tokens_start : tokens_start + self.condition_lengths[i]]
									UpperCamelCase__       =							self.transformer_index_for_condition[i]
									UpperCamelCase__       =							self.transformers[transformer_index](
									    a_   ,    encoder_hidden_states=a_   ,    timestep=a_   ,    cross_attention_kwargs=a_   ,    return_dict=a_   ,    )[0]
									encoded_states.append(encoded_state - input_states  )
									tokens_start += self.condition_lengths[i]

						UpperCamelCase__       =							encoded_states[0] * self.mix_ratio + encoded_states[1] * (1 - self.mix_ratio)
						UpperCamelCase__       =							output_states + input_states

						if not return_dict:
									return (output_states,)

						return TransformeraDModelOutput(sample=a_  )





'''simple docstring'''




import qiskit


def    lowerCamelCase__		(    SCREAMING_SNAKE_CASE   : int							, SCREAMING_SNAKE_CASE   : int    ):
  UpperCAmelCase    				=						qiskit.Aer.get_backend('aer_simulator'    )

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

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

  # Execute the circuit on the simulator
  UpperCAmelCase    				=						qiskit.execute(SCREAMING_SNAKE_CASE							, SCREAMING_SNAKE_CASE							, shots=1000    )

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


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


