



'''simple docstring'''



import argparse

import numpy as np
import torch

from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging


logging.set_verbosity_info()
lowerCamelCase									=							logging.get_logger("""transformers.models.speecht5""")



def 	_A							( _lowerCAmelCase	, _lowerCAmelCase	, _lowerCAmelCase       ):



							"""simple docstring"""



							hf_model.apply_weight_norm()

							__lowercase													=checkpoint['''input_conv.weight_g''']
							__lowercase													=checkpoint['''input_conv.weight_v''']
							__lowercase													=checkpoint['''input_conv.bias''']

							for i in range(len(config.upsample_rates       )       ):
														__lowercase													=checkpoint[f"""upsamples.{i}.1.weight_g"""]
														__lowercase													=checkpoint[f"""upsamples.{i}.1.weight_v"""]
														__lowercase													=checkpoint[f"""upsamples.{i}.1.bias"""]

							for i in range(len(config.upsample_rates       ) * len(config.resblock_kernel_sizes       )       ):
														for j in range(len(config.resblock_dilation_sizes       )       ):
																					__lowercase													=checkpoint[f"""blocks.{i}.convs1.{j}.1.weight_g"""]
																					__lowercase													=checkpoint[f"""blocks.{i}.convs1.{j}.1.weight_v"""]
																					__lowercase													=checkpoint[f"""blocks.{i}.convs1.{j}.1.bias"""]

																					__lowercase													=checkpoint[f"""blocks.{i}.convs2.{j}.1.weight_g"""]
																					__lowercase													=checkpoint[f"""blocks.{i}.convs2.{j}.1.weight_v"""]
																					__lowercase													=checkpoint[f"""blocks.{i}.convs2.{j}.1.bias"""]

							__lowercase													=checkpoint['''output_conv.1.weight_g''']
							__lowercase													=checkpoint['''output_conv.1.weight_v''']
							__lowercase													=checkpoint['''output_conv.1.bias''']

							hf_model.remove_weight_norm()



@torch.no_grad()
def 	_A							( _lowerCAmelCase	, _lowerCAmelCase	, _lowerCAmelCase	, _lowerCAmelCase=None	, _lowerCAmelCase=None	, ):



							"""simple docstring"""



							if config_path is not None:
														__lowercase													=SpeechTaHifiGanConfig.from_pretrained(UpperCAmelCase_       )
							else:
														__lowercase													=SpeechTaHifiGanConfig()

							__lowercase													=SpeechTaHifiGan(UpperCAmelCase_       )

							__lowercase													=torch.load(UpperCAmelCase_       )
							load_weights(orig_checkpoint['model']['generator']	, UpperCAmelCase_	, UpperCAmelCase_       )

							__lowercase													=np.load(UpperCAmelCase_       )
							__lowercase													=stats[0].reshape(-1       )
							__lowercase													=stats[1].reshape(-1       )
							__lowercase													=torch.from_numpy(UpperCAmelCase_       ).float()
							__lowercase													=torch.from_numpy(UpperCAmelCase_       ).float()

							model.save_pretrained(UpperCAmelCase_       )

							if repo_id:
														print('Pushing to the hub...'       )
														model.push_to_hub(UpperCAmelCase_       )


if __name__ == "__main__":
		lowerCamelCase									=							argparse.ArgumentParser()
		parser.add_argument("""--checkpoint_path""", required=True, default=None, type=str, help="""Path to original checkpoint""")
		parser.add_argument("""--stats_path""", required=True, default=None, type=str, help="""Path to stats.npy file""")
		parser.add_argument("""--config_path""", default=None, type=str, help="""Path to hf config.json of model to convert""")
		parser.add_argument(
		    """--pytorch_dump_folder_path""", required=True, default=None, type=str, help="""Path to the output PyTorch model."""
		)
		parser.add_argument(
		    """--push_to_hub""", default=None, type=str, help="""Where to upload the converted model on the 🤗 hub."""
		)

		lowerCamelCase									=							parser.parse_args()
		convert_hifigan_checkpoint(
		    args.checkpoint_path,
		    args.stats_path,
		    args.pytorch_dump_folder_path,
		    args.config_path,
		    args.push_to_hub,
		)







import qiskit
def 							__lowerCamelCase		(					UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						int		):




      """simple docstring"""





      a		:Tuple									=			qiskit.Aer.get_backend('''aer_simulator'''		)

      # Create a Quantum Circuit acting on the q register
      a		:str									=			qiskit.QuantumCircuit(UpperCAmelCase_					,    UpperCAmelCase_		)

      # Apply X (NOT) Gate to Qubits 0 & 1
      circuit.x(0		)
      circuit.x(1		)

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

      # Execute the circuit on the qasm simulator
      a		:Optional[Any]									=			qiskit.execute(UpperCAmelCase_					,    UpperCAmelCase_					,    shots=1000		)

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


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





