




"""simple docstring"""




import math

import numpy as np
import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute







def 			__UpperCAmelCase			(      __UpperCamelCase = 3     ):



			if isinstance(__UpperCamelCase     ,							__UpperCamelCase     ):
						raise TypeError('''number of qubits must be a integer.'''     )
			if number_of_qubits <= 0:
						raise ValueError('''number of qubits must be > 0.'''     )
			if math.floor(__UpperCamelCase     ) != number_of_qubits:
						raise ValueError('''number of qubits must be exact integer.'''     )
			if number_of_qubits > 10:
						raise ValueError('''number of qubits too large to simulate(>10).'''     )

			__lowercase       :   int        =    QuantumRegister(__UpperCamelCase     ,							'''qr'''     )
			__lowercase       :   str        =    ClassicalRegister(__UpperCamelCase     ,							'''cr'''     )

			__lowercase       :   str        =    QuantumCircuit(__UpperCamelCase     ,							__UpperCamelCase     )

			__lowercase       :   List[Any]        =    number_of_qubits

			for i in range(__UpperCamelCase     ):
						quantum_circuit.h(number_of_qubits - i - 1     )
						counter -= 1
						for j in range(__UpperCamelCase     ):
									quantum_circuit.cp(np.pi / 2 ** (counter - j)     ,							__UpperCamelCase     ,							__UpperCamelCase     )

			for k in range(number_of_qubits // 2     ):
						quantum_circuit.swap(__UpperCamelCase     ,							number_of_qubits - k - 1     )

			# measure all the qubits
			quantum_circuit.measure(__UpperCamelCase     ,							__UpperCamelCase     )
			# simulate with 10000 shots
			__lowercase       :   str        =    Aer.get_backend('''qasm_simulator'''     )
			__lowercase       :   Dict        =    execute(__UpperCamelCase     ,							__UpperCamelCase     ,							shots=1_00_00     )

			return job.result().get_counts(__UpperCamelCase     )


if __name__ == "__main__":
			print(
			    F"Total count for quantum fourier transform state is: \\n    {quantum_fourier_transform(3)}"
			)











# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ..models.whisper import WhisperForConditionalGeneration, WhisperProcessor
from .base import PipelineTool

class     _SCREAMING_SNAKE_CASE       (			_a      ):
	snake_case__							:     Any     	=  """openai/whisper-base"""
	snake_case__							:     Optional[int]     	=  (
	    """This is a tool that transcribes an audio into text. It takes an input named `audio` and returns the """
	    """transcribed text."""
	)
	snake_case__							:     Any     	=  """transcriber"""
	snake_case__							:     Optional[int]     	=  WhisperProcessor
	snake_case__							:     str     	=  WhisperForConditionalGeneration

	snake_case__							:     Optional[Any]     	=  ["""audio"""]
	snake_case__							:     Any     	=  ["""text"""]





	def 						_A (		self				:					str ,  __lowerCamelCase				:					Dict	):
		return self.pre_processor(__lowerCamelCase ,  return_tensors="""pt"""	).input_features





	def 						_A (		self				:					Dict ,  __lowerCamelCase				:					List[Any]	):
		return self.model.generate(inputs=__lowerCamelCase	)





	def 						_A (		self				:					Any ,  __lowerCamelCase				:					Optional[Any]	):
		return self.pre_processor.batch_decode(__lowerCamelCase ,  skip_special_tokens=__lowerCamelCase	)[0]
