
import csv

import tweepy

# Twitter API credentials
__a  			=					''
__a  			=					''
__a  			=					''
__a  			=					''




def 				a						(							snake_case__:					str					):


				'''simple docstring'''
				# authorize twitter, initialize tweepy
				lowercase_       =					tweepy.OAuthHandler(snake_case__						,   snake_case__					)
				auth.set_access_token(snake_case__						,   snake_case__					)
				lowercase_       =					tweepy.API(snake_case__					)

				# initialize a list to hold all the tweepy Tweets
				lowercase_       =					[]

				# make initial request for most recent tweets (200 is the maximum allowed count)
				lowercase_       =					api.user_timeline(screen_name=snake_case__						,   count=200					)

				# save most recent tweets
				alltweets.extend(snake_case__					)

				# save the id of the oldest tweet less one
				lowercase_       =					alltweets[-1].id - 1

				# keep grabbing tweets until there are no tweets left to grab
				while len(snake_case__					) > 0:
								print(F'''getting tweets before {oldest}'''					)

								# all subsequent requests use the max_id param to prevent duplicates
								lowercase_       =					api.user_timeline(
								    screen_name=snake_case__						,   count=200						,   max_id=snake_case__					)

								# save most recent tweets
								alltweets.extend(snake_case__					)

								# update the id of the oldest tweet less one
								lowercase_       =					alltweets[-1].id - 1

								print(F'''...{len(snake_case__					)} tweets downloaded so far'''					)

				# transform the tweepy tweets into a 2D array that will populate the csv
				lowercase_       =					[[tweet.id_str, tweet.created_at, tweet.text] for tweet in alltweets]

				# write the csv
				with open(F'''new_{screen_name}_tweets.csv'''						,   '''w'''					) as f:
								lowercase_       =					csv.writer(snake_case__					)
								writer.writerow(['''id''', '''created_at''', '''text''']					)
								writer.writerows(snake_case__					)


if __name__ == "__main__":
						# pass in the username of the account you want to download
						get_all_tweets('FirePing32')





'''simple docstring'''

import argparse

import pytorch_lightning as pl
import torch
from torch import nn

from transformers import LongformerForQuestionAnswering, LongformerModel



class 			UpperCAmelCase  (						pl.LightningModule					):





       '''simple docstring'''



       def __init__(						self	,   __lowerCAmelCase )  ->  List[str]:
        super().__init__()
        lowercase__				:    List[str]  =					model
        lowercase__				:    Dict  =					2
        lowercase__				:    Any  =					nn.Linear(self.model.config.hidden_size	,   self.num_labels )


       def _lowerCAmelCase(						self )  ->  str:
        pass


def 			__UpperCamelCase       (   UpperCAmelCase		,     UpperCAmelCase		,     UpperCAmelCase     ):
 # load longformer model from model identifier
 lowercase__				:    Dict  =					LongformerModel.from_pretrained(UpperCAmelCase     )
 lowercase__				:    List[str]  =					LightningModel(UpperCAmelCase     )

 lowercase__				:    List[Any]  =					torch.load(UpperCAmelCase		,     map_location=torch.device('''cpu'''     )     )
 lightning_model.load_state_dict(ckpt['''state_dict''']     )

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

