

'''simple docstring'''
import argparse

import pytorch_lightning as pl
import torch
from torch import nn

from transformers import LongformerForQuestionAnswering, LongformerModel
class 					_snake_case		(pl.LightningModule):






			def __init__(  self			,_snake_case     ):
				super().__init__()
				UpperCAmelCase_     :      Any						=  model
				UpperCAmelCase_     :      Optional[int]						=  2
				UpperCAmelCase_     :      List[Any]						=  nn.Linear(self.model.config.hidden_size			,self.num_labels     )






			def 		UpperCamelCase__							(  self     ):
				pass




def  a__       (    _SCREAMING_SNAKE_CASE   :       str	,				_SCREAMING_SNAKE_CASE   :       str	,				_SCREAMING_SNAKE_CASE   :       str				)     ->					int:


	"""simple docstring"""





	UpperCAmelCase_     :      Tuple						=  LongformerModel.from_pretrained(UpperCamelCase__				)
	UpperCAmelCase_     :      Union[str, Any]						=  LightningModel(UpperCamelCase__				)

	UpperCAmelCase_     :      Any						=  torch.load(UpperCamelCase__	,				map_location=torch.device("cpu"				)				)
	lightning_model.load_state_dict(ckpt["state_dict"]				)

	# init longformer question answering model
	UpperCAmelCase_     :      str						=  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      					=     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      					=     parser.parse_args()
					convert_longformer_qa_checkpoint_to_pytorch(
					    args.longformer_model, args.longformer_question_answering_ckpt_path, args.pytorch_dump_folder_path
					)





'''simple docstring'''


def    lowerCAmelCase       (		UpperCamelCase__					: list							):


	"""simple docstring"""
	__UpperCAmelCase      					=      False
	while is_sorted is False:  # Until all the indices are traversed keep looping
		__UpperCAmelCase      					=      True
		for i in range(0     ,       len(UpperCamelCase__							) - 1     ,       2							):  # iterating over all even indices
			if input_list[i] > input_list[i + 1]:
				__UpperCAmelCase					,      __UpperCAmelCase      					=      input_list[i + 1], input_list[i]
				# swapping if elements not in order
				__UpperCAmelCase      					=      False

		for i in range(1     ,       len(UpperCamelCase__							) - 1     ,       2							):  # iterating over all odd indices
			if input_list[i] > input_list[i + 1]:
				__UpperCAmelCase					,      __UpperCAmelCase      					=      input_list[i + 1], input_list[i]
				# swapping if elements not in order
				__UpperCAmelCase      					=      False
	return input_list


if __name__ == "__main__":
					print("Enter list to be sorted")
					__lowerCAmelCase						:							List[str]    							=						[int(x) for x in input().split()]
					# inputing elements of the list in one line
					__lowerCAmelCase						:							Dict    							=						odd_even_sort(input_list)
					print("The sorted list is")
					print(sorted_list)
