



"""simple docstring"""





import math

import numpy as np
import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute
def      a__			(   lowerCAmelCase__ = 3   ):
      if isinstance(lowerCAmelCase__			,    lowerCAmelCase__   ):
            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(lowerCAmelCase__   ) != 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)."   )

      UpperCAmelCase_    				=							QuantumRegister(lowerCAmelCase__			,    "qr"   )
      UpperCAmelCase_    				=							ClassicalRegister(lowerCAmelCase__			,    "cr"   )

      UpperCAmelCase_    				=							QuantumCircuit(lowerCAmelCase__			,    lowerCAmelCase__   )

      UpperCAmelCase_    				=							number_of_qubits

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

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

      # measure all the qubits
      quantum_circuit.measure(lowerCAmelCase__			,    lowerCAmelCase__   )
      # simulate with 10000 shots
      UpperCAmelCase_    				=							Aer.get_backend("qasm_simulator"   )
      UpperCAmelCase_    				=							execute(lowerCAmelCase__			,    lowerCAmelCase__			,    shots=10000   )

      return job.result().get_counts(lowerCAmelCase__   )


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




"""simple docstring"""





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tokenizers_available,
    is_torch_available,
    is_vision_available,
)


lowerCamelCase      =		{
    """configuration_perceiver""": ["""PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PerceiverConfig""", """PerceiverOnnxConfig"""],
    """tokenization_perceiver""": ["""PerceiverTokenizer"""],
}

try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowerCamelCase      =		["""PerceiverFeatureExtractor"""]
  lowerCamelCase      =		["""PerceiverImageProcessor"""]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowerCamelCase      =		[
      """PERCEIVER_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """PerceiverForImageClassificationConvProcessing""",
      """PerceiverForImageClassificationFourier""",
      """PerceiverForImageClassificationLearned""",
      """PerceiverForMaskedLM""",
      """PerceiverForMultimodalAutoencoding""",
      """PerceiverForOpticalFlow""",
      """PerceiverForSequenceClassification""",
      """PerceiverLayer""",
      """PerceiverModel""",
      """PerceiverPreTrainedModel""",
  ]


if TYPE_CHECKING:
  from .configuration_perceiver import PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP, PerceiverConfig, PerceiverOnnxConfig
  from .tokenization_perceiver import PerceiverTokenizer

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .feature_extraction_perceiver import PerceiverFeatureExtractor
    from .image_processing_perceiver import PerceiverImageProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_perceiver import (
        PERCEIVER_PRETRAINED_MODEL_ARCHIVE_LIST,
        PerceiverForImageClassificationConvProcessing,
        PerceiverForImageClassificationFourier,
        PerceiverForImageClassificationLearned,
        PerceiverForMaskedLM,
        PerceiverForMultimodalAutoencoding,
        PerceiverForOpticalFlow,
        PerceiverForSequenceClassification,
        PerceiverLayer,
        PerceiverModel,
        PerceiverPreTrainedModel,
    )

else:
  import sys

  lowerCamelCase      =		_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




