





import argparse

import pytorch_lightning as pl
import torch
from torch import nn

from transformers import LongformerForQuestionAnswering, LongformerModel


class 						lowerCamelCase       (pl.LightningModule      ):







							"""simple docstring"""




							def __init__( self     :					List[str],			_UpperCAmelCase     :					Optional[Any]						)				->			int:





														"""simple docstring"""
														super().__init__()
														SCREAMING_SNAKE_CASE__       :      List[str]     =						model
														SCREAMING_SNAKE_CASE__       :      Dict     =						2
														SCREAMING_SNAKE_CASE__       :      Dict     =						nn.Linear(self.model.config.hidden_size,			self.num_labels						)






							def  A_     ( self     :					Optional[Any]						)				->			Optional[Any]:





														"""simple docstring"""
														pass




def _a (  SCREAMING_SNAKE_CASE__      :  int			,				SCREAMING_SNAKE_CASE__      :  Optional[Any]			,				SCREAMING_SNAKE_CASE__      :  int       )	->    Any:

							'''simple docstring'''






							SCREAMING_SNAKE_CASE__       :      List[str]     =						LongformerModel.from_pretrained(_UpperCAmelCase       )
							SCREAMING_SNAKE_CASE__       :      Dict     =						LightningModel(_UpperCAmelCase       )

							SCREAMING_SNAKE_CASE__       :      List[Any]     =						torch.load(_UpperCAmelCase			,				map_location=torch.device("cpu"       )       )
							lightning_model.load_state_dict(ckpt["state_dict"]       )

							# init longformer question answering model
							SCREAMING_SNAKE_CASE__       :      Dict     =						LongformerForQuestionAnswering.from_pretrained(_UpperCAmelCase       )

							# transfer weights
							longformer_for_qa.longformer.load_state_dict(lightning_model.model.state_dict()       )
							longformer_for_qa.qa_outputs.load_state_dict(lightning_model.qa_outputs.state_dict()       )
							longformer_for_qa.eval()

							# save model
							longformer_for_qa.save_pretrained(_UpperCAmelCase       )

							print(f'''Conversion successful. Model saved under {pytorch_dump_folder_path}'''       )


if __name__ == "__main__":
						_lowerCamelCase :    Optional[int]  							= argparse.ArgumentParser()
						# Required parameters
						parser.add_argument(
						    '''--longformer_model''',
						    default=None,
						    type=str,
						    required=True,
						    help='''model identifier of longformer. Should be either `longformer-base-4096` or `longformer-large-4096`.''',
						)
						parser.add_argument(
						    '''--longformer_question_answering_ckpt_path''',
						    default=None,
						    type=str,
						    required=True,
						    help='''Path the official PyTorch Lightning Checkpoint.''',
						)
						parser.add_argument(
						    '''--pytorch_dump_folder_path''', default=None, type=str, required=True, help='''Path to the output PyTorch model.'''
						)
						_lowerCamelCase :    Any  							= parser.parse_args()
						convert_longformer_qa_checkpoint_to_pytorch(
						    args.longformer_model, args.longformer_question_answering_ckpt_path, args.pytorch_dump_folder_path
						)













import qiskit




def _a (  SCREAMING_SNAKE_CASE__      :  int			,				SCREAMING_SNAKE_CASE__      :  int       )	->    qiskit.result.counts.Counts:

							'''simple docstring'''






							SCREAMING_SNAKE_CASE__       :      Union[str, Any]     =						qiskit.Aer.get_backend("aer_simulator"       )

							# Create a Quantum Circuit acting on the q register
							SCREAMING_SNAKE_CASE__       :      List[Any]     =						qiskit.QuantumCircuit(SCREAMING_SNAKE_CASE__			,				SCREAMING_SNAKE_CASE__       )

							# 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
							SCREAMING_SNAKE_CASE__       :      int     =						qiskit.execute(SCREAMING_SNAKE_CASE__			,				SCREAMING_SNAKE_CASE__			,				shots=10_00       )

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


if __name__ == "__main__":
		_lowerCamelCase :    List[str]  							= single_qubit_measure(2, 2)
		print(f"Total count for various states are: {counts}")






