




from functools import lru_cache

def  SCREAMING_SNAKE_CASE							(       __UpperCamelCase)      ->					set:
     a     =				2
     a     =				set()
     while i * i <= n:
          if n % i:
               i += 1
          else:
               n //= i
               factors.add(__UpperCamelCase)
     if n > 1:
          factors.add(__UpperCamelCase)
     return factors

@lru_cache
def  SCREAMING_SNAKE_CASE							(       __UpperCamelCase)      ->					int:
     return len(unique_prime_factors(__UpperCamelCase))

def  SCREAMING_SNAKE_CASE							(       __UpperCamelCase)      ->					bool:
     return len(set(__UpperCamelCase)) in (0, 1)

def  SCREAMING_SNAKE_CASE							(       __UpperCamelCase)      ->					list:
     a     =				2

     while True:
          # Increment each value of a generated range
          a     =				[base + i for i in range(__UpperCamelCase)]

          # Run elements through out unique_prime_factors function
          # Append our target number to the end.
          a     =				[upf_len(__UpperCamelCase) for x in group]
          checker.append(__UpperCamelCase)

          # If all numbers in the list are equal, return the group variable.
          if equality(__UpperCamelCase):
               return group

          # Increment our base variable by 1
          base += 1

def  SCREAMING_SNAKE_CASE							(       __UpperCamelCase = 4)      ->					int:
     a     =				run(__UpperCamelCase)
     return results[0] if len(__UpperCamelCase) else None


if __name__ == "__main__":
   print(solution())







import argparse

import pytorch_lightning as pl
import torch
from torch import nn

from transformers import LongformerForQuestionAnswering, LongformerModel




class       a__	( pl.LightningModule				):







     def __init__(     self  ,		A			)  ->   Optional[Any]:



          '''simple docstring'''



          super().__init__()
          a     =				model
          a     =				2
          a     =				nn.Linear(self.model.config.hidden_size  ,		self.num_labels			)







     def       lowerCAmelCase_    (     self			)  ->   List[Any]:



          '''simple docstring'''



          pass







def  SCREAMING_SNAKE_CASE							(       __UpperCamelCase		, __UpperCamelCase		, __UpperCamelCase)      ->					List[Any]:
     # load longformer model from model identifier
     a     =				LongformerModel.from_pretrained(__UpperCamelCase)
     a     =				LightningModel(__UpperCamelCase)

     a     =				torch.load(__UpperCamelCase		, map_location=torch.device("cpu"))
     lightning_model.load_state_dict(ckpt["state_dict"])

     # init longformer question answering model
     a     =				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__":
   lowercase__				:      Optional[Any]	   = 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."
   )
   lowercase__				:      Union[str, Any]	   = parser.parse_args()
   convert_longformer_qa_checkpoint_to_pytorch(
       args.longformer_model, args.longformer_question_answering_ckpt_path, args.pytorch_dump_folder_path
   )

