




import argparse

import torch

from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


logging.set_verbosity_info()


def    A						(__A   :    Tuple   ,				__A   :    Optional[Any]   ,				__A   :    Optional[int]       )   ->      List[str]:







     """simple docstring"""


     if gpta_config_file == "":
          UpperCAmelCase_          =							GPTaConfig()
     else:
          UpperCAmelCase_          =							GPTaConfig.from_json_file(__lowerCamelCase       )
     UpperCAmelCase_          =							GPTaModel(__lowerCamelCase       )

     # Load weights from numpy
     load_tf_weights_in_gpta(__lowerCamelCase   ,				__lowerCamelCase   ,				__lowerCamelCase       )

     # Save pytorch-model
     UpperCAmelCase_          =							pytorch_dump_folder_path + '''/''' + WEIGHTS_NAME
     UpperCAmelCase_          =							pytorch_dump_folder_path + '''/''' + CONFIG_NAME
     print(F"""Save PyTorch model to {pytorch_weights_dump_path}"""       )
     torch.save(model.state_dict()   ,				__lowerCamelCase       )
     print(F"""Save configuration file to {pytorch_config_dump_path}"""       )
     with open(__lowerCamelCase   ,				'''w'''   ,				encoding='''utf-8'''       ) as f:
          f.write(config.to_json_string()       )


if __name__ == "__main__":
    snake_case_ : str    		=       argparse.ArgumentParser()
    # Required parameters
    parser.add_argument(
        "--gpt2_checkpoint_path", default=None, type=str, required=True, help="Path to the TensorFlow checkpoint path."
    )
    parser.add_argument(
        "--pytorch_dump_folder_path", default=None, type=str, required=True, help="Path to the output PyTorch model."
    )
    parser.add_argument(
        "--gpt2_config_file",
        default="",
        type=str,
        help=(
            "An optional config json file corresponding to the pre-trained OpenAI model. \n"
            "This specifies the model architecture."
        ),
    )
    snake_case_ : str    		=       parser.parse_args()
    convert_gpta_checkpoint_to_pytorch(args.gpta_checkpoint_path, args.gpta_config_file, args.pytorch_dump_folder_path)








"""simple docstring"""



import math

import numpy as np
import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute
def 					_UpperCAmelCase      ( __lowerCamelCase   :       int = 3		)     ->					qiskit.result.counts.Counts:
  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).'''		)

  _snake_case					     =       QuantumRegister(__lowerCamelCase ,					'''qr'''		)
  _snake_case					     =       ClassicalRegister(__lowerCamelCase ,					'''cr'''		)

  _snake_case					     =       QuantumCircuit(__lowerCamelCase ,					__lowerCamelCase		)

  _snake_case					     =       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
  _snake_case					     =       Aer.get_backend('''qasm_simulator'''		)
  _snake_case					     =       execute(__lowerCamelCase ,					__lowerCamelCase ,					shots=1_00_00		)

  return job.result().get_counts(__lowerCamelCase		)


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



