





import math

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




def       __UpperCamelCase  (_SCREAMING_SNAKE_CASE = 3		)    ->       qiskit.result.counts.Counts:
  if isinstance(_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE		):
    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(_SCREAMING_SNAKE_CASE		) != 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__           =  QuantumRegister(_SCREAMING_SNAKE_CASE		,						'qr'		)
  lowercase__           =  ClassicalRegister(_SCREAMING_SNAKE_CASE		,						'cr'		)

  lowercase__           =  QuantumCircuit(_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE		)

  lowercase__           =  number_of_qubits

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

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

  # measure all the qubits
  quantum_circuit.measure(_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE		)
  # simulate with 10000 shots
  lowercase__           =  Aer.get_backend('qasm_simulator'		)
  lowercase__           =  execute(_SCREAMING_SNAKE_CASE		,						_SCREAMING_SNAKE_CASE		,						shots=10000		)

  return job.result().get_counts(_SCREAMING_SNAKE_CASE		)


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









from typing import Callable, Optional

from .. import Features
from ..packaged_modules.generator.generator import Generator
from .abc import AbstractDatasetInputStream
class     SCREAMING_SNAKE_CASE       (UpperCAmelCase				):


   def __init__(   self      :    List[str]      ,					a      :    Callable      ,					a      :    Optional[Features] = None      ,					a      :    str = None      ,					a      :    bool = False      ,					a      :    bool = False      ,					a      :    Optional[dict] = None      ,					a      :    Optional[int] = None      ,					**a      :    str      ,					)->       Tuple:





     """simple docstring"""







     super().__init__(
         features=a      ,					cache_dir=a      ,					keep_in_memory=a      ,					streaming=a      ,					num_proc=a      ,					**a      ,					)
     lowercase__           =  Generator(
         cache_dir=a      ,					features=a      ,					generator=a      ,					gen_kwargs=a      ,					**a      ,					)


   def 	SCREAMING_SNAKE_CASE_							(   self      :    Any	)->       Dict:





     """simple docstring"""







     if self.streaming:
       lowercase__           =  self.builder.as_streaming_dataset(split='train'	)
     # Build regular (map-style) dataset
     else:
       lowercase__           =  None
       lowercase__           =  None
       lowercase__           =  None
       lowercase__           =  None

       self.builder.download_and_prepare(
           download_config=a      ,					download_mode=a      ,					verification_mode=a      ,					base_path=a      ,					num_proc=self.num_proc      ,					)
       lowercase__           =  self.builder.as_dataset(
           split='train'      ,					verification_mode=a      ,					in_memory=self.keep_in_memory	)
     return dataset


