






"""simple docstring"""


import torch
from torch import nn

from ...configuration_utils import ConfigMixin, register_to_config
from ...models import ModelMixin




class 						__UpperCamelCase     (     UpperCamelCase   ,     UpperCamelCase						):
					@register_to_config
					def __init__(							self							:	int     , *,
					    UpperCAmelCase							:	int = 4     , UpperCAmelCase							:	int = 768     , UpperCAmelCase							:	int     , UpperCAmelCase							:	Any     , )	->       Any:
											super().__init__()

											lowerCAmelCase   :int						=			nn.Parameter(torch.zeros(UpperCAmelCase   )   )

											# parameters for additional clip time embeddings
											lowerCAmelCase   :Union[str, Any]						=			nn.Linear(UpperCAmelCase     , UpperCAmelCase   )
											lowerCAmelCase   :Optional[int]						=			nn.Linear(UpperCAmelCase     , UpperCAmelCase   )

											# parameters for encoder hidden states
											lowerCAmelCase   :Optional[Any]						=			clip_extra_context_tokens
											lowerCAmelCase   :int						=			nn.Linear(
											    UpperCAmelCase     , self.clip_extra_context_tokens * cross_attention_dim   )
											lowerCAmelCase   :Tuple						=			nn.Linear(UpperCAmelCase     , UpperCAmelCase   )
											lowerCAmelCase   :int						=			nn.LayerNorm(UpperCAmelCase   )
					def        UpperCAmelCase__ (							self							:	Optional[Any]     , *, UpperCAmelCase							:	Dict     , UpperCAmelCase							:	Optional[Any]     , UpperCAmelCase							:	Optional[int]     , UpperCAmelCase							:	Optional[Any]   )	->       Optional[int]:
											if do_classifier_free_guidance:
																	# Add the classifier free guidance embeddings to the image embeddings
																	lowerCAmelCase   :List[Any]						=			image_embeddings.shape[0]
																	lowerCAmelCase   :str						=			self.learned_classifier_free_guidance_embeddings.unsqueeze(0   )
																	lowerCAmelCase   :Optional[Any]						=			classifier_free_guidance_embeddings.expand(
																	    UpperCAmelCase     , -1   )
																	lowerCAmelCase   :Optional[int]						=			torch.cat([classifier_free_guidance_embeddings, image_embeddings]     , dim=0   )

											# The image embeddings batch size and the text embeddings batch size are equal
											assert image_embeddings.shape[0] == prompt_embeds.shape[0]

											lowerCAmelCase   :List[Any]						=			prompt_embeds.shape[0]

											# "Specifically, we modify the architecture described in Nichol et al. (2021) by projecting and
											# adding CLIP embeddings to the existing timestep embedding, ...
											lowerCAmelCase   :Tuple						=			self.embedding_proj(UpperCAmelCase   )
											lowerCAmelCase   :Dict						=			self.clip_image_embeddings_project_to_time_embeddings(UpperCAmelCase   )
											lowerCAmelCase   :Union[str, Any]						=			time_projected_image_embeddings + time_projected_prompt_embeds

											# ... and by projecting CLIP embeddings into four
											# extra tokens of context that are concatenated to the sequence of outputs from the GLIDE text encoder"
											lowerCAmelCase   :int						=			self.clip_extra_context_tokens_proj(UpperCAmelCase   )
											lowerCAmelCase   :int						=			clip_extra_context_tokens.reshape(UpperCAmelCase     , -1     , self.clip_extra_context_tokens   )
											lowerCAmelCase   :int						=			clip_extra_context_tokens.permute(0     , 2     , 1   )

											lowerCAmelCase   :List[Any]						=			self.encoder_hidden_states_proj(UpperCAmelCase   )
											lowerCAmelCase   :Dict						=			self.text_encoder_hidden_states_norm(UpperCAmelCase   )
											lowerCAmelCase   :Dict						=			torch.cat([clip_extra_context_tokens, text_encoder_hidden_states]     , dim=1   )

											return text_encoder_hidden_states, additive_clip_time_embeddings







"""simple docstring"""


import qiskit


def        UpperCAmelCase      (					a__     ,      a__ ):





						'''simple docstring'''






						lowerCAmelCase   :List[Any]						=			qiskit.Aer.get_backend('aer_simulator' )

						# Create a Quantum Circuit acting on the q register
						lowerCAmelCase   :Optional[int]						=			qiskit.QuantumCircuit(a__     ,      a__ )

						# Apply X (NOT) Gate to Qubits 0 & 1
						circuit.x(0 )
						circuit.x(1 )

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

						# Execute the circuit on the qasm simulator
						lowerCAmelCase   :Dict						=			qiskit.execute(a__     ,      a__     ,      shots=10_00 )

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


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