


'''simple docstring'''
from collections import OrderedDict
from typing import Any, Mapping, Optional

from ... import PreTrainedTokenizer
from ...configuration_utils import PretrainedConfig
from ...file_utils import TensorType, is_torch_available
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import logging


__snake_case							   =  logging.get_logger(__name__)

__snake_case							   =  {
    '''facebook/blenderbot_small-90M''': '''https://huggingface.co/facebook/blenderbot_small-90M/resolve/main/config.json''',
    # See all BlenderbotSmall models at https://huggingface.co/models?filter=blenderbot_small
}
class      lowercase			(							A__      ):

		"""simple docstring"""

		_a									=       'blenderbot-small'
		_a									=       ['past_key_values']
		_a									=       {'num_attention_heads': 'encoder_attention_heads', 'hidden_size': 'd_model'}




		def __init__(	self					,     UpperCamelCase_=50265					,     UpperCamelCase_=512					,     UpperCamelCase_=8					,     UpperCamelCase_=2048					,     UpperCamelCase_=16					,     UpperCamelCase_=8					,     UpperCamelCase_=2048					,     UpperCamelCase_=16					,     UpperCamelCase_=0.0					,     UpperCamelCase_=0.0					,     UpperCamelCase_=True					,     UpperCamelCase_=True					,     UpperCamelCase_="gelu"					,     UpperCamelCase_=512					,     UpperCamelCase_=0.1					,     UpperCamelCase_=0.0					,     UpperCamelCase_=0.0					,     UpperCamelCase_=0.02					,     UpperCamelCase_=1					,     UpperCamelCase_=False					,     UpperCamelCase_=0					,     UpperCamelCase_=1					,     UpperCamelCase_=2					,     UpperCamelCase_=2					,     **UpperCamelCase_					,     ):

							'''simple docstring'''


							UpperCamelCase__     :Optional[Any]							      =				vocab_size
							UpperCamelCase__     :List[str]							      =				max_position_embeddings
							UpperCamelCase__     :Union[str, Any]							      =				d_model
							UpperCamelCase__     :Optional[int]							      =				encoder_ffn_dim
							UpperCamelCase__     :Optional[Any]							      =				encoder_layers
							UpperCamelCase__     :Optional[Any]							      =				encoder_attention_heads
							UpperCamelCase__     :List[str]							      =				decoder_ffn_dim
							UpperCamelCase__     :Optional[int]							      =				decoder_layers
							UpperCamelCase__     :Optional[Any]							      =				decoder_attention_heads
							UpperCamelCase__     :Any							      =				dropout
							UpperCamelCase__     :Union[str, Any]							      =				attention_dropout
							UpperCamelCase__     :Any							      =				activation_dropout
							UpperCamelCase__     :Any							      =				activation_function
							UpperCamelCase__     :Dict							      =				init_std
							UpperCamelCase__     :int							      =				encoder_layerdrop
							UpperCamelCase__     :Optional[Any]							      =				decoder_layerdrop
							UpperCamelCase__     :Any							      =				use_cache
							UpperCamelCase__     :Optional[Any]							      =				encoder_layers
							UpperCamelCase__     :str							      =				scale_embedding  # scale factor will be sqrt(d_model) if True

							super().__init__(
							    pad_token_id=UpperCamelCase_					,     bos_token_id=UpperCamelCase_					,     eos_token_id=UpperCamelCase_					,     is_encoder_decoder=UpperCamelCase_					,     decoder_start_token_id=UpperCamelCase_					,     forced_eos_token_id=UpperCamelCase_					,     **UpperCamelCase_					,     )



class      lowercase			(							A__      ):

		"""simple docstring"""

		@property
		def 					lowerCAmelCase__       (	self							):

							'''simple docstring'''


							if self.task in ["default", "seq2seq-lm"]:
												UpperCamelCase__     :Optional[Any]							      =				OrderedDict(
												    [
												        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
												        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
												    ]							)

												if self.use_past:
																	UpperCamelCase__     :int							      =				{0: '''batch'''}
																	UpperCamelCase__     :List[str]							      =				{0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
												else:
																	UpperCamelCase__     :List[str]							      =				{0: '''batch''', 1: '''decoder_sequence'''}
																	UpperCamelCase__     :Optional[Any]							      =				{0: '''batch''', 1: '''decoder_sequence'''}

												if self.use_past:
																	self.fill_with_past_key_values_(UpperCamelCase_					,     direction='''inputs'''							)
							elif self.task == "causal-lm":
												# TODO: figure this case out.
												UpperCamelCase__     :str							      =				OrderedDict(
												    [
												        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
												        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
												    ]							)
												if self.use_past:
																	UpperCamelCase__      ,       UpperCamelCase__     :Optional[int]							      =				self.num_layers
																	for i in range(UpperCamelCase_							):
																						UpperCamelCase__     :Dict							      =				{0: '''batch''', 2: '''past_sequence + sequence'''}
																						UpperCamelCase__     :int							      =				{0: '''batch''', 2: '''past_sequence + sequence'''}
							else:
												UpperCamelCase__     :int							      =				OrderedDict(
												    [
												        ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
												        ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
												        ('''decoder_input_ids''', {0: '''batch''', 1: '''decoder_sequence'''}),
												        ('''decoder_attention_mask''', {0: '''batch''', 1: '''decoder_sequence'''}),
												    ]							)

							return common_inputs




		@property
		def 					lowerCAmelCase__       (	self							):

							'''simple docstring'''


							if self.task in ["default", "seq2seq-lm"]:
												UpperCamelCase__     :Any							      =				super().outputs
							else:
												UpperCamelCase__     :Dict							      =				super(UpperCamelCase_					,     self							).outputs
												if self.use_past:
																	UpperCamelCase__      ,       UpperCamelCase__     :Optional[Any]							      =				self.num_layers
																	for i in range(UpperCamelCase_							):
																						UpperCamelCase__     :Optional[int]							      =				{0: '''batch''', 2: '''past_sequence + sequence'''}
																						UpperCamelCase__     :Union[str, Any]							      =				{0: '''batch''', 2: '''past_sequence + sequence'''}
							return common_outputs




		def 					lowerCAmelCase__       (	self					,     UpperCamelCase_					,     UpperCamelCase_ = -1					,     UpperCamelCase_ = -1					,     UpperCamelCase_ = False					,     UpperCamelCase_ = None					,     ):

							'''simple docstring'''


							UpperCamelCase__     :Optional[int]							      =				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
							    UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_							)

							# Generate decoder inputs
							UpperCamelCase__     :Optional[int]							      =				seq_length if not self.use_past else 1
							UpperCamelCase__     :Any							      =				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
							    UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_							)
							UpperCamelCase__     :int							      =				{F'''decoder_{name}''': tensor for name, tensor in decoder_inputs.items()}
							UpperCamelCase__     :List[str]							      =				dict(**UpperCamelCase_					,     **UpperCamelCase_							)

							if self.use_past:
												if not is_torch_available():
																	raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''							)
												else:
																	import torch
												UpperCamelCase__      ,       UpperCamelCase__     :Any							      =				common_inputs['''input_ids'''].shape
												UpperCamelCase__     :Dict							      =				common_inputs['''decoder_input_ids'''].shape[1]
												UpperCamelCase__      ,       UpperCamelCase__     :List[Any]							      =				self.num_attention_heads
												UpperCamelCase__     :Optional[Any]							      =				(
												    batch,
												    num_encoder_attention_heads,
												    encoder_seq_length,
												    self._config.hidden_size // num_encoder_attention_heads,
												)
												UpperCamelCase__     :Dict							      =				decoder_seq_length + 3
												UpperCamelCase__     :Dict							      =				(
												    batch,
												    num_decoder_attention_heads,
												    decoder_past_length,
												    self._config.hidden_size // num_decoder_attention_heads,
												)

												UpperCamelCase__     :int							      =				torch.cat(
												    [common_inputs['''decoder_attention_mask'''], torch.ones(UpperCamelCase_					,     UpperCamelCase_							)]					,     dim=1							)

												UpperCamelCase__     :Union[str, Any]							      =				[]
												# If the number of encoder and decoder layers are present in the model configuration, both are considered
												UpperCamelCase__      ,       UpperCamelCase__     :Dict							      =				self.num_layers
												UpperCamelCase__     :List[Any]							      =				min(UpperCamelCase_					,     UpperCamelCase_							)
												UpperCamelCase__     :Any							      =				max(UpperCamelCase_					,     UpperCamelCase_							) - min_num_layers
												UpperCamelCase__     :Dict							      =				'''encoder''' if num_encoder_layers > num_decoder_layers else '''decoder'''

												for _ in range(UpperCamelCase_							):
																	common_inputs["past_key_values"].append(
																	    (
																	        torch.zeros(UpperCamelCase_							),
																	        torch.zeros(UpperCamelCase_							),
																	        torch.zeros(UpperCamelCase_							),
																	        torch.zeros(UpperCamelCase_							),
																	    )							)
												# TODO: test this.
												UpperCamelCase__     :Optional[Any]							      =				encoder_shape if remaining_side_name == '''encoder''' else decoder_shape
												for _ in range(UpperCamelCase_					,     UpperCamelCase_							):
																	common_inputs["past_key_values"].append((torch.zeros(UpperCamelCase_							), torch.zeros(UpperCamelCase_							))							)
							return common_inputs




		def 					lowerCAmelCase__       (	self					,     UpperCamelCase_					,     UpperCamelCase_ = -1					,     UpperCamelCase_ = -1					,     UpperCamelCase_ = False					,     UpperCamelCase_ = None					,     ):

							'''simple docstring'''


							UpperCamelCase__     :int							      =				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
							    UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_							)

							if self.use_past:
												if not is_torch_available():
																	raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''							)
												else:
																	import torch
												UpperCamelCase__      ,       UpperCamelCase__     :Any							      =				common_inputs['''input_ids'''].shape
												# Not using the same length for past_key_values
												UpperCamelCase__     :Dict							      =				seqlen + 2
												UpperCamelCase__      ,       UpperCamelCase__     :str							      =				self.num_layers
												UpperCamelCase__      ,       UpperCamelCase__     :Union[str, Any]							      =				self.num_attention_heads
												UpperCamelCase__     :str							      =				(
												    batch,
												    num_encoder_attention_heads,
												    past_key_values_length,
												    self._config.hidden_size // num_encoder_attention_heads,
												)

												UpperCamelCase__     :List[str]							      =				common_inputs['''attention_mask'''].dtype
												UpperCamelCase__     :Union[str, Any]							      =				torch.cat(
												    [common_inputs['''attention_mask'''], torch.ones(UpperCamelCase_					,     UpperCamelCase_					,     dtype=UpperCamelCase_							)]					,     dim=1							)
												UpperCamelCase__     :Dict							      =				[
												    (torch.zeros(UpperCamelCase_							), torch.zeros(UpperCamelCase_							)) for _ in range(UpperCamelCase_							)
												]
							return common_inputs




		def 					lowerCAmelCase__       (	self					,     UpperCamelCase_					,     UpperCamelCase_ = -1					,     UpperCamelCase_ = -1					,     UpperCamelCase_ = False					,     UpperCamelCase_ = None					,     ):

							'''simple docstring'''


							UpperCamelCase__     :Dict							      =				compute_effective_axis_dimension(
							    UpperCamelCase_					,     fixed_dimension=OnnxConfig.default_fixed_batch					,     num_token_to_add=0							)

							# If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
							UpperCamelCase__     :Union[str, Any]							      =				tokenizer.num_special_tokens_to_add(UpperCamelCase_							)
							UpperCamelCase__     :Optional[Any]							      =				compute_effective_axis_dimension(
							    UpperCamelCase_					,     fixed_dimension=OnnxConfig.default_fixed_sequence					,     num_token_to_add=UpperCamelCase_							)

							# Generate dummy inputs according to compute batch and sequence
							UpperCamelCase__     :Dict							      =				[''' '''.join([tokenizer.unk_token]							) * seq_length] * batch_size
							UpperCamelCase__     :Union[str, Any]							      =				dict(tokenizer(UpperCamelCase_					,     return_tensors=UpperCamelCase_							)							)
							return common_inputs




		def 					lowerCAmelCase__       (	self					,     UpperCamelCase_					,     UpperCamelCase_ = -1					,     UpperCamelCase_ = -1					,     UpperCamelCase_ = False					,     UpperCamelCase_ = None					,     ):

							'''simple docstring'''


							if self.task in ["default", "seq2seq-lm"]:
												UpperCamelCase__     :Dict							      =				self._generate_dummy_inputs_for_default_and_seqaseq_lm(
												    UpperCamelCase_					,     batch_size=UpperCamelCase_					,     seq_length=UpperCamelCase_					,     is_pair=UpperCamelCase_					,     framework=UpperCamelCase_							)

							elif self.task == "causal-lm":
												UpperCamelCase__     :Optional[Any]							      =				self._generate_dummy_inputs_for_causal_lm(
												    UpperCamelCase_					,     batch_size=UpperCamelCase_					,     seq_length=UpperCamelCase_					,     is_pair=UpperCamelCase_					,     framework=UpperCamelCase_							)
							else:
												UpperCamelCase__     :Union[str, Any]							      =				self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
												    UpperCamelCase_					,     batch_size=UpperCamelCase_					,     seq_length=UpperCamelCase_					,     is_pair=UpperCamelCase_					,     framework=UpperCamelCase_							)

							return common_inputs




		def 					lowerCAmelCase__       (	self					,     UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_							):

							'''simple docstring'''


							if self.task in ["default", "seq2seq-lm"]:
												UpperCamelCase__     :List[Any]							      =				super()._flatten_past_key_values_(UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_							)
							else:
												UpperCamelCase__     :str							      =				super(UpperCamelCase_					,     self							)._flatten_past_key_values_(
												    UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_					,     UpperCamelCase_							)



'''simple docstring'''
import qiskit


def     a   (    __a				,      __a     )						->			qiskit.result.counts.Counts:



					'''simple docstring'''






					UpperCamelCase__     :int							      =				qiskit.Aer.get_backend('''aer_simulator'''     )

					# Create a Quantum Circuit acting on the q register
					UpperCamelCase__     :Any							      =				qiskit.QuantumCircuit(__a				,      __a     )

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

					# Execute the circuit on the simulator
					UpperCamelCase__     :Optional[int]							      =				qiskit.execute(__a				,      __a				,      shots=1000     )

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


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