





import argparse
import os
import sys
import urllib.request
import zipfile


__UpperCAmelCase			:  Union[str, Any]										=				["CoLA", "SST", "MRPC", "QQP", "STS", "MNLI", "SNLI", "QNLI", "RTE", "WNLI", "diagnostic"]
__UpperCAmelCase			:  Optional[int]										=				{
    "CoLA": "https://firebasestorage.googleapis.com/v0/b/mtl-sentence-representations.appspot.com/o/data%2FCoLA.zip?alt=media&token=46d5e637-3411-4188-bc44-5809b5bfb5f4",
    "SST": "https://firebasestorage.googleapis.com/v0/b/mtl-sentence-representations.appspot.com/o/data%2FSST-2.zip?alt=media&token=aabc5f6b-e466-44a2-b9b4-cf6337f84ac8",
    "MRPC": "https://firebasestorage.googleapis.com/v0/b/mtl-sentence-representations.appspot.com/o/data%2Fmrpc_dev_ids.tsv?alt=media&token=ec5c0836-31d5-48f4-b431-7480817f1adc",
    "QQP": "https://firebasestorage.googleapis.com/v0/b/mtl-sentence-representations.appspot.com/o/data%2FQQP.zip?alt=media&token=700c6acf-160d-4d89-81d1-de4191d02cb5",
    "STS": "https://firebasestorage.googleapis.com/v0/b/mtl-sentence-representations.appspot.com/o/data%2FSTS-B.zip?alt=media&token=bddb94a7-8706-4e0d-a694-1109e12273b5",
    "MNLI": "https://firebasestorage.googleapis.com/v0/b/mtl-sentence-representations.appspot.com/o/data%2FMNLI.zip?alt=media&token=50329ea1-e339-40e2-809c-10c40afff3ce",
    "SNLI": "https://firebasestorage.googleapis.com/v0/b/mtl-sentence-representations.appspot.com/o/data%2FSNLI.zip?alt=media&token=4afcfbb2-ff0c-4b2d-a09a-dbf07926f4df",
    "QNLI": "https://firebasestorage.googleapis.com/v0/b/mtl-sentence-representations.appspot.com/o/data%2FQNLIv2.zip?alt=media&token=6fdcf570-0fc5-4631-8456-9505272d1601",
    "RTE": "https://firebasestorage.googleapis.com/v0/b/mtl-sentence-representations.appspot.com/o/data%2FRTE.zip?alt=media&token=5efa7e85-a0bb-4f19-8ea2-9e1840f077fb",
    "WNLI": "https://firebasestorage.googleapis.com/v0/b/mtl-sentence-representations.appspot.com/o/data%2FWNLI.zip?alt=media&token=068ad0a0-ded7-4bd7-99a5-5e00222e0faf",
    "diagnostic": "https://storage.googleapis.com/mtl-sentence-representations.appspot.com/tsvsWithoutLabels%2FAX.tsv?GoogleAccessId=firebase-adminsdk-0khhl@mtl-sentence-representations.iam.gserviceaccount.com&Expires=2498860800&Signature=DuQ2CSPt2Yfre0C%2BiISrVYrIFaZH1Lc7hBVZDD4ZyR7fZYOMNOUGpi8QxBmTNOrNPjR3z1cggo7WXFfrgECP6FBJSsURv8Ybrue8Ypt%2FTPxbuJ0Xc2FhDi%2BarnecCBFO77RSbfuz%2Bs95hRrYhTnByqu3U%2FYZPaj3tZt5QdfpH2IUROY8LiBXoXS46LE%2FgOQc%2FKN%2BA9SoscRDYsnxHfG0IjXGwHN%2Bf88q6hOmAxeNPx6moDulUF6XMUAaXCSFU%2BnRO2RDL9CapWxj%2BDl7syNyHhB7987hZ80B%2FwFkQ3MEs8auvt5XW1%2Bd4aCU7ytgM69r8JDCwibfhZxpaa4gd50QXQ%3D%3D",
}

__UpperCAmelCase			:  List[Any]										=				"https://dl.fbaipublicfiles.com/senteval/senteval_data/msr_paraphrase_train.txt"
__UpperCAmelCase			:  Dict										=				"https://dl.fbaipublicfiles.com/senteval/senteval_data/msr_paraphrase_test.txt"







def      A__				(       SCREAMING_SNAKE_CASE__   ,   SCREAMING_SNAKE_CASE__)  ->       List[Any]:
  print(F'''Downloading and extracting {task}...''')
  __snake_case:		Tuple					    =		F'''{task}.zip'''
  urllib.request.urlretrieve(TASKaPATH[task]   ,   SCREAMING_SNAKE_CASE__)
  with zipfile.ZipFile(SCREAMING_SNAKE_CASE__) as zip_ref:
    zip_ref.extractall(SCREAMING_SNAKE_CASE__)
  os.remove(SCREAMING_SNAKE_CASE__)
  print("""\tCompleted!""")







def      A__				(       SCREAMING_SNAKE_CASE__   ,   SCREAMING_SNAKE_CASE__)  ->       Any:
  print("""Processing MRPC...""")
  __snake_case:		Dict					    =		os.path.join(SCREAMING_SNAKE_CASE__   ,   """MRPC""")
  if not os.path.isdir(SCREAMING_SNAKE_CASE__):
    os.mkdir(SCREAMING_SNAKE_CASE__)
  if path_to_data:
    __snake_case:		Tuple					    =		os.path.join(SCREAMING_SNAKE_CASE__   ,   """msr_paraphrase_train.txt""")
    __snake_case:		Union[str, Any]					    =		os.path.join(SCREAMING_SNAKE_CASE__   ,   """msr_paraphrase_test.txt""")
  else:
    print("""Local MRPC data not specified, downloading data from %s""" % MRPC_TRAIN)
    __snake_case:		Dict					    =		os.path.join(SCREAMING_SNAKE_CASE__   ,   """msr_paraphrase_train.txt""")
    __snake_case:		int					    =		os.path.join(SCREAMING_SNAKE_CASE__   ,   """msr_paraphrase_test.txt""")
    urllib.request.urlretrieve(SCREAMING_SNAKE_CASE__   ,   SCREAMING_SNAKE_CASE__)
    urllib.request.urlretrieve(SCREAMING_SNAKE_CASE__   ,   SCREAMING_SNAKE_CASE__)
  if not os.path.isfile(SCREAMING_SNAKE_CASE__):
    raise ValueError(F'''Train data not found at {mrpc_train_file}''')
  if not os.path.isfile(SCREAMING_SNAKE_CASE__):
    raise ValueError(F'''Test data not found at {mrpc_test_file}''')
  urllib.request.urlretrieve(TASKaPATH["""MRPC"""]   ,   os.path.join(SCREAMING_SNAKE_CASE__   ,   """dev_ids.tsv"""))

  __snake_case:		Tuple					    =		[]
  with open(os.path.join(SCREAMING_SNAKE_CASE__   ,   """dev_ids.tsv""")   ,   encoding="""utf8""") as ids_fh:
    for row in ids_fh:
      dev_ids.append(row.strip().split("""\t"""))

  with open(SCREAMING_SNAKE_CASE__   ,   encoding="""utf8""") as data_fh, open(
      os.path.join(SCREAMING_SNAKE_CASE__   ,   """train.tsv""")   ,   """w"""   ,   encoding="""utf8""") as train_fh, open(os.path.join(SCREAMING_SNAKE_CASE__   ,   """dev.tsv""")   ,   """w"""   ,   encoding="""utf8""") as dev_fh:
    __snake_case:		Tuple					    =		data_fh.readline()
    train_fh.write(SCREAMING_SNAKE_CASE__)
    dev_fh.write(SCREAMING_SNAKE_CASE__)
    for row in data_fh:
      __snake_case    ,  __snake_case    ,  __snake_case    ,  __snake_case    ,  __snake_case:		Tuple					    =		row.strip().split("""\t""")
      if [ida, ida] in dev_ids:
        dev_fh.write("""%s\t%s\t%s\t%s\t%s\n""" % (label, ida, ida, sa, sa))
      else:
        train_fh.write("""%s\t%s\t%s\t%s\t%s\n""" % (label, ida, ida, sa, sa))

  with open(SCREAMING_SNAKE_CASE__   ,   encoding="""utf8""") as data_fh, open(
      os.path.join(SCREAMING_SNAKE_CASE__   ,   """test.tsv""")   ,   """w"""   ,   encoding="""utf8""") as test_fh:
    __snake_case:		int					    =		data_fh.readline()
    test_fh.write("""index\t#1 ID\t#2 ID\t#1 String\t#2 String\n""")
    for idx, row in enumerate(SCREAMING_SNAKE_CASE__):
      __snake_case    ,  __snake_case    ,  __snake_case    ,  __snake_case    ,  __snake_case:		Optional[int]					    =		row.strip().split("""\t""")
      test_fh.write("""%d\t%s\t%s\t%s\t%s\n""" % (idx, ida, ida, sa, sa))
  print("""\tCompleted!""")







def      A__				(       SCREAMING_SNAKE_CASE__)  ->       List[Any]:
  print("""Downloading and extracting diagnostic...""")
  if not os.path.isdir(os.path.join(SCREAMING_SNAKE_CASE__   ,   """diagnostic""")):
    os.mkdir(os.path.join(SCREAMING_SNAKE_CASE__   ,   """diagnostic"""))
  __snake_case:		List[str]					    =		os.path.join(SCREAMING_SNAKE_CASE__   ,   """diagnostic"""   ,   """diagnostic.tsv""")
  urllib.request.urlretrieve(TASKaPATH["""diagnostic"""]   ,   SCREAMING_SNAKE_CASE__)
  print("""\tCompleted!""")
  return







def      A__				(       SCREAMING_SNAKE_CASE__)  ->       List[Any]:
  __snake_case:		Union[str, Any]					    =		task_names.split(""",""")
  if "all" in task_names:
    __snake_case:		List[Any]					    =		TASKS
  else:
    __snake_case:		List[str]					    =		[]
    for task_name in task_names:
      if task_name not in TASKS:
        raise ValueError(F'''Task {task_name} not found!''')
      tasks.append(SCREAMING_SNAKE_CASE__)
  return tasks







def      A__				(       SCREAMING_SNAKE_CASE__)  ->       Dict:
  __snake_case:		Optional[int]					    =		argparse.ArgumentParser()
  parser.add_argument("""--data_dir"""   ,   help="""directory to save data to"""   ,   type=SCREAMING_SNAKE_CASE__   ,   default="""glue_data""")
  parser.add_argument(
      """--tasks"""   ,   help="""tasks to download data for as a comma separated string"""   ,   type=SCREAMING_SNAKE_CASE__   ,   default="""all""")
  parser.add_argument(
      """--path_to_mrpc"""   ,   help="""path to directory containing extracted MRPC data, msr_paraphrase_train.txt and msr_paraphrase_text.txt"""   ,   type=SCREAMING_SNAKE_CASE__   ,   default=""""""   ,   )
  __snake_case:		Any					    =		parser.parse_args(SCREAMING_SNAKE_CASE__)

  if not os.path.isdir(args.data_dir):
    os.mkdir(args.data_dir)
  __snake_case:		Tuple					    =		get_tasks(args.tasks)

  for task in tasks:
    if task == "MRPC":
      format_mrpc(args.data_dir   ,   args.path_to_mrpc)
    elif task == "diagnostic":
      download_diagnostic(args.data_dir)
    else:
      download_and_extract(SCREAMING_SNAKE_CASE__   ,   args.data_dir)


if __name__ == "__main__":
      sys.exit(main(sys.argv[1:]))













import unittest

from transformers import YosoConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
      import torch

      from transformers import (
          YosoForMaskedLM,
          YosoForMultipleChoice,
          YosoForQuestionAnswering,
          YosoForSequenceClassification,
          YosoForTokenClassification,
          YosoModel,
      )
      from transformers.models.yoso.modeling_yoso import YOSO_PRETRAINED_MODEL_ARCHIVE_LIST







class        __snake_case			:





       '''simple docstring'''







       def __init__(    self					:       Union[str, Any]				,							A					:       Optional[Any]				,							A					:       str=13				,							A					:       List[Any]=7				,							A					:       str=True				,							A					:       Optional[int]=True				,							A					:       Any=True				,							A					:       List[str]=True				,							A					:       str=99				,							A					:       str=32				,							A					:       Any=5				,							A					:       Any=4				,							A					:       str=37				,							A					:       List[Any]="gelu"				,							A					:       Union[str, Any]=0.1				,							A					:       str=0.1				,							A					:       List[Any]=512				,							A					:       Optional[int]=16				,							A					:       List[str]=2				,							A					:       Optional[int]=0.02				,							A					:       Optional[int]=3				,							A					:       int=4				,							A					:       List[Any]=None				,							):
         __snake_case:		Any					    =		parent
         __snake_case:		Optional[int]					    =		batch_size
         __snake_case:		Optional[int]					    =		seq_length
         __snake_case:		Any					    =		is_training
         __snake_case:		int					    =		use_input_mask
         __snake_case:		Tuple					    =		use_token_type_ids
         __snake_case:		Optional[Any]					    =		use_labels
         __snake_case:		Optional[Any]					    =		vocab_size
         __snake_case:		str					    =		hidden_size
         __snake_case:		int					    =		num_hidden_layers
         __snake_case:		Optional[int]					    =		num_attention_heads
         __snake_case:		Tuple					    =		intermediate_size
         __snake_case:		Optional[int]					    =		hidden_act
         __snake_case:		Union[str, Any]					    =		hidden_dropout_prob
         __snake_case:		Any					    =		attention_probs_dropout_prob
         __snake_case:		List[str]					    =		max_position_embeddings
         __snake_case:		Any					    =		type_vocab_size
         __snake_case:		Dict					    =		type_sequence_label_size
         __snake_case:		int					    =		initializer_range
         __snake_case:		Union[str, Any]					    =		num_labels
         __snake_case:		int					    =		num_choices
         __snake_case:		List[Any]					    =		scope




       def 				UpperCAmelCase__					(    self					:       List[Any]						):
         __snake_case:		Any					    =		ids_tensor([self.batch_size, self.seq_length]				,							self.vocab_size						)

         __snake_case:		Any					    =		None
         if self.use_input_mask:
           __snake_case:		str					    =		random_attention_mask([self.batch_size, self.seq_length]						)

         __snake_case:		Tuple					    =		None
         if self.use_token_type_ids:
           __snake_case:		Tuple					    =		ids_tensor([self.batch_size, self.seq_length]				,							self.type_vocab_size						)

         __snake_case:		int					    =		None
         __snake_case:		Union[str, Any]					    =		None
         __snake_case:		str					    =		None
         if self.use_labels:
           __snake_case:		str					    =		ids_tensor([self.batch_size]				,							self.type_sequence_label_size						)
           __snake_case:		int					    =		ids_tensor([self.batch_size, self.seq_length]				,							self.num_labels						)
           __snake_case:		Tuple					    =		ids_tensor([self.batch_size]				,							self.num_choices						)

         __snake_case:		List[str]					    =		self.get_config()

         return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels




       def 				UpperCAmelCase__					(    self					:       Union[str, Any]						):
         return YosoConfig(
             vocab_size=self.vocab_size				,							hidden_size=self.hidden_size				,							num_hidden_layers=self.num_hidden_layers				,							num_attention_heads=self.num_attention_heads				,							intermediate_size=self.intermediate_size				,							hidden_act=self.hidden_act				,							hidden_dropout_prob=self.hidden_dropout_prob				,							attention_probs_dropout_prob=self.attention_probs_dropout_prob				,							max_position_embeddings=self.max_position_embeddings				,							type_vocab_size=self.type_vocab_size				,							is_decoder=A				,							initializer_range=self.initializer_range				,							)




       def 				UpperCAmelCase__					(    self					:       Any						):
         __snake_case:		str					    =		self.get_config()
         __snake_case:		Optional[Any]					    =		300
         return config




       def 				UpperCAmelCase__					(    self					:       Optional[Any]						):
         (
             (
             __snake_case
         )    ,  (
             __snake_case
         )    ,  (
             __snake_case
         )    ,  (
             __snake_case
         )    ,  (
             __snake_case
         )    ,  (
             __snake_case
         )    ,  (
             __snake_case
         )    ,  
         ):		List[str]					    =		self.prepare_config_and_inputs()

         __snake_case:		Optional[Any]					    =		True
         __snake_case:		Optional[Any]					    =		floats_tensor([self.batch_size, self.seq_length, self.hidden_size]						)
         __snake_case:		Tuple					    =		ids_tensor([self.batch_size, self.seq_length]				,							vocab_size=2						)

         return (
             config,
             input_ids,
             token_type_ids,
             input_mask,
             sequence_labels,
             token_labels,
             choice_labels,
             encoder_hidden_states,
             encoder_attention_mask,
         )




       def 				UpperCAmelCase__					(    self					:       Any				,							A					:       Dict				,							A					:       str				,							A					:       Tuple				,							A					:       Dict				,							A					:       List[str]				,							A					:       List[str]				,							A					:       Optional[int]						):
         __snake_case:		Optional[int]					    =		YosoModel(config=A						)
         model.to(A						)
         model.eval()
         __snake_case:		List[Any]					    =		model(A				,							attention_mask=A				,							token_type_ids=A						)
         __snake_case:		str					    =		model(A				,							token_type_ids=A						)
         __snake_case:		int					    =		model(A						)
         self.parent.assertEqual(result.last_hidden_state.shape				,							(self.batch_size, self.seq_length, self.hidden_size)						)




       def 				UpperCAmelCase__					(    self					:       Optional[int]				,							A					:       Dict				,							A					:       int				,							A					:       str				,							A					:       List[str]				,							A					:       int				,							A					:       Optional[int]				,							A					:       str				,							A					:       Optional[int]				,							A					:       str				,							):
         __snake_case:		Optional[Any]					    =		True
         __snake_case:		List[str]					    =		YosoModel(A						)
         model.to(A						)
         model.eval()
         __snake_case:		Optional[int]					    =		model(
             A				,							attention_mask=A				,							token_type_ids=A				,							encoder_hidden_states=A				,							encoder_attention_mask=A				,							)
         __snake_case:		Optional[int]					    =		model(
             A				,							attention_mask=A				,							token_type_ids=A				,							encoder_hidden_states=A				,							)
         __snake_case:		Optional[int]					    =		model(A				,							attention_mask=A				,							token_type_ids=A						)
         self.parent.assertEqual(result.last_hidden_state.shape				,							(self.batch_size, self.seq_length, self.hidden_size)						)




       def 				UpperCAmelCase__					(    self					:       Optional[Any]				,							A					:       str				,							A					:       Optional[int]				,							A					:       List[Any]				,							A					:       Optional[Any]				,							A					:       Dict				,							A					:       int				,							A					:       Optional[int]						):
         __snake_case:		List[str]					    =		YosoForMaskedLM(config=A						)
         model.to(A						)
         model.eval()
         __snake_case:		int					    =		model(A				,							attention_mask=A				,							token_type_ids=A				,							labels=A						)
         self.parent.assertEqual(result.logits.shape				,							(self.batch_size, self.seq_length, self.vocab_size)						)




       def 				UpperCAmelCase__					(    self					:       int				,							A					:       Any				,							A					:       Union[str, Any]				,							A					:       Optional[int]				,							A					:       Any				,							A					:       int				,							A					:       Any				,							A					:       Optional[int]						):
         __snake_case:		int					    =		YosoForQuestionAnswering(config=A						)
         model.to(A						)
         model.eval()
         __snake_case:		Any					    =		model(
             A				,							attention_mask=A				,							token_type_ids=A				,							start_positions=A				,							end_positions=A				,							)
         self.parent.assertEqual(result.start_logits.shape				,							(self.batch_size, self.seq_length)						)
         self.parent.assertEqual(result.end_logits.shape				,							(self.batch_size, self.seq_length)						)




       def 				UpperCAmelCase__					(    self					:       str				,							A					:       Union[str, Any]				,							A					:       Tuple				,							A					:       Union[str, Any]				,							A					:       int				,							A					:       Optional[int]				,							A					:       int				,							A					:       List[Any]						):
         __snake_case:		Union[str, Any]					    =		self.num_labels
         __snake_case:		Union[str, Any]					    =		YosoForSequenceClassification(A						)
         model.to(A						)
         model.eval()
         __snake_case:		Optional[int]					    =		model(A				,							attention_mask=A				,							token_type_ids=A				,							labels=A						)
         self.parent.assertEqual(result.logits.shape				,							(self.batch_size, self.num_labels)						)




       def 				UpperCAmelCase__					(    self					:       Dict				,							A					:       Optional[int]				,							A					:       Dict				,							A					:       Any				,							A					:       Dict				,							A					:       str				,							A					:       int				,							A					:       Optional[int]						):
         __snake_case:		List[Any]					    =		self.num_labels
         __snake_case:		Union[str, Any]					    =		YosoForTokenClassification(config=A						)
         model.to(A						)
         model.eval()
         __snake_case:		List[Any]					    =		model(A				,							attention_mask=A				,							token_type_ids=A				,							labels=A						)
         self.parent.assertEqual(result.logits.shape				,							(self.batch_size, self.seq_length, self.num_labels)						)




       def 				UpperCAmelCase__					(    self					:       List[str]				,							A					:       Union[str, Any]				,							A					:       Tuple				,							A					:       int				,							A					:       Dict				,							A					:       Optional[int]				,							A					:       str				,							A					:       Optional[Any]						):
         __snake_case:		List[Any]					    =		self.num_choices
         __snake_case:		List[Any]					    =		YosoForMultipleChoice(config=A						)
         model.to(A						)
         model.eval()
         __snake_case:		str					    =		input_ids.unsqueeze(1						).expand(-1				,							self.num_choices				,							-1						).contiguous()
         __snake_case:		Any					    =		token_type_ids.unsqueeze(1						).expand(-1				,							self.num_choices				,							-1						).contiguous()
         __snake_case:		Optional[int]					    =		input_mask.unsqueeze(1						).expand(-1				,							self.num_choices				,							-1						).contiguous()
         __snake_case:		Any					    =		model(
             A				,							attention_mask=A				,							token_type_ids=A				,							labels=A				,							)
         self.parent.assertEqual(result.logits.shape				,							(self.batch_size, self.num_choices)						)






       def 				UpperCAmelCase__					(    self					:       List[Any]						):
         __snake_case:		List[str]					    =		self.prepare_config_and_inputs()
         (
             (
             __snake_case
         )    ,  (
             __snake_case
         )    ,  (
             __snake_case
         )    ,  (
             __snake_case
         )    ,  (
             __snake_case
         )    ,  (
             __snake_case
         )    ,  (
             __snake_case
         )    ,  
         ):		int					    =		config_and_inputs
         __snake_case:		str					    =		{"""input_ids""": input_ids, """token_type_ids""": token_type_ids, """attention_mask""": input_mask}
         return config, inputs_dict







@require_torch
class        __snake_case			(				__lowerCamelCase  ,     __lowerCamelCase  ,     unittest.TestCase     ):





       '''simple docstring'''







       lowerCAmelCase__ 						=	(
           (
               YosoModel,
               YosoForMaskedLM,
               YosoForMultipleChoice,
               YosoForQuestionAnswering,
               YosoForSequenceClassification,
               YosoForTokenClassification,
           )
           if is_torch_available()
           else ()
       )
       lowerCAmelCase__ 						=	False
       lowerCAmelCase__ 						=	False
       lowerCAmelCase__ 						=	False

       lowerCAmelCase__ 						=	()
       lowerCAmelCase__ 						=	(
           {
               """feature-extraction""": YosoModel,
               """fill-mask""": YosoForMaskedLM,
               """question-answering""": YosoForQuestionAnswering,
               """text-classification""": YosoForSequenceClassification,
               """token-classification""": YosoForTokenClassification,
               """zero-shot""": YosoForSequenceClassification,
           }
           if is_torch_available()
           else {}
       )




       def 				UpperCAmelCase__					(    self					:       str						):
         __snake_case:		List[str]					    =		YosoModelTester(self						)
         __snake_case:		Optional[int]					    =		ConfigTester(self				,							config_class=A				,							hidden_size=37						)




       def 				UpperCAmelCase__					(    self					:       List[str]						):
         self.config_tester.run_common_tests()




       def 				UpperCAmelCase__					(    self					:       Optional[int]						):
         __snake_case:		Union[str, Any]					    =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_model(*A						)




       def 				UpperCAmelCase__					(    self					:       Union[str, Any]						):
         __snake_case:		Optional[Any]					    =		self.model_tester.prepare_config_and_inputs()
         for type in ["absolute", "relative_key", "relative_key_query"]:
           __snake_case:		Optional[Any]					    =		type
           self.model_tester.create_and_check_model(*A						)




       def 				UpperCAmelCase__					(    self					:       str						):
         __snake_case:		List[Any]					    =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_masked_lm(*A						)




       def 				UpperCAmelCase__					(    self					:       List[Any]						):
         __snake_case:		List[str]					    =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_multiple_choice(*A						)




       def 				UpperCAmelCase__					(    self					:       int						):
         __snake_case:		Any					    =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_question_answering(*A						)




       def 				UpperCAmelCase__					(    self					:       Optional[Any]						):
         __snake_case:		List[Any]					    =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_sequence_classification(*A						)




       def 				UpperCAmelCase__					(    self					:       List[str]						):
         __snake_case:		Optional[int]					    =		self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_for_token_classification(*A						)




       @slow
       def 				UpperCAmelCase__					(    self					:       Any						):
         for model_name in YOSO_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           __snake_case:		str					    =		YosoModel.from_pretrained(A						)
           self.assertIsNotNone(A						)






       def 				UpperCAmelCase__					(    self					:       Tuple						):
         return







@require_torch
class        __snake_case			(				unittest.TestCase     ):





       '''simple docstring'''







       @slow
       def 				UpperCAmelCase__					(    self					:       Tuple						):
         __snake_case:		Any					    =		YosoModel.from_pretrained("""uw-madison/yoso-4096"""						)
         __snake_case:		Union[str, Any]					    =		torch.tensor([[0, 1, 2, 3, 4, 5]]						)

         with torch.no_grad():
           __snake_case:		Optional[Any]					    =		model(A						)[0]

         __snake_case:		List[str]					    =		torch.Size((1, 6, 768)						)
         self.assertEqual(output.shape				,							A						)

         __snake_case:		List[Any]					    =		torch.tensor(
             [[[-0.0611, 0.1242, 0.0840], [0.0280, -0.0048, 0.1125], [0.0106, 0.0226, 0.0751]]]						)

         self.assertTrue(torch.allclose(output[:, :3, :3]				,							A				,							atol=1E-4						)						)




       @slow
       def 				UpperCAmelCase__					(    self					:       Optional[Any]						):
         __snake_case:		Optional[Any]					    =		YosoForMaskedLM.from_pretrained("""uw-madison/yoso-4096"""						)
         __snake_case:		Tuple					    =		torch.tensor([[0, 1, 2, 3, 4, 5]]						)

         with torch.no_grad():
           __snake_case:		Optional[int]					    =		model(A						)[0]

         __snake_case:		Tuple					    =		50_265

         __snake_case:		List[str]					    =		torch.Size((1, 6, vocab_size)						)
         self.assertEqual(output.shape				,							A						)

         __snake_case:		Any					    =		torch.tensor(
             [[[-2.1313, -3.7285, -2.2407], [-2.7047, -3.3314, -2.6408], [0.0629, -2.5166, -0.3356]]]						)

         self.assertTrue(torch.allclose(output[:, :3, :3]				,							A				,							atol=1E-4						)						)






       @slow
       def 				UpperCAmelCase__					(    self					:       Any						):
         __snake_case:		int					    =		YosoForMaskedLM.from_pretrained("""uw-madison/yoso-4096"""						)
         __snake_case:		Optional[Any]					    =		torch.arange(4_096						).unsqueeze(0						)

         with torch.no_grad():
           __snake_case:		Tuple					    =		model(A						)[0]

         __snake_case:		List[str]					    =		50_265

         __snake_case:		Union[str, Any]					    =		torch.Size((1, 4_096, vocab_size)						)
         self.assertEqual(output.shape				,							A						)

         __snake_case:		List[str]					    =		torch.tensor(
             [[[-2.3914, -4.3742, -5.0956], [-4.0988, -4.2384, -7.0406], [-3.1427, -3.7192, -6.6800]]]						)

         self.assertTrue(torch.allclose(output[:, :3, :3]				,							A				,							atol=1E-4						)						)






