



"""simple docstring"""





import unittest

from transformers import GPTNeoXJapaneseConfig, is_torch_available
from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer
from transformers.testing_utils import require_torch, slow, torch_device

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


if is_torch_available():
  import torch

  from transformers import GPTNeoXJapaneseForCausalLM, GPTNeoXJapaneseModel
class  lowercase__  :







       '''simple docstring'''


       def __init__(				self     :    List[Any]						,							_UpperCAmelCase     :    Optional[Any]						,							_UpperCAmelCase     :    Any=13						,							_UpperCAmelCase     :    int=7						,							_UpperCAmelCase     :    List[Any]=True						,							_UpperCAmelCase     :    Union[str, Any]=True						,							_UpperCAmelCase     :    Union[str, Any]=True						,							_UpperCAmelCase     :    List[str]=True						,							_UpperCAmelCase     :    int=99						,							_UpperCAmelCase     :    Optional[int]=32						,							_UpperCAmelCase     :    str=5						,							_UpperCAmelCase     :    List[Any]=4						,							_UpperCAmelCase     :    int=4						,							_UpperCAmelCase     :    str="gelu"						,							_UpperCAmelCase     :    Union[str, Any]=0.0						,							_UpperCAmelCase     :    List[str]=0.1						,							_UpperCAmelCase     :    int=True						,							_UpperCAmelCase     :    str=512						,							_UpperCAmelCase     :    str=16						,							_UpperCAmelCase     :    List[Any]=2						,							_UpperCAmelCase     :    Dict=0.02						,							_UpperCAmelCase     :    Optional[int]=3						,							_UpperCAmelCase     :    Any=4						,							_UpperCAmelCase     :    Tuple=None						,							)					->		Tuple:


             '''simple docstring'''




             UpperCAmelCase_     					=				parent
             UpperCAmelCase_     					=				batch_size
             UpperCAmelCase_     					=				seq_length
             UpperCAmelCase_     					=				is_training
             UpperCAmelCase_     					=				use_input_mask
             UpperCAmelCase_     					=				use_token_type_ids
             UpperCAmelCase_     					=				use_labels
             UpperCAmelCase_     					=				vocab_size
             UpperCAmelCase_     					=				hidden_size
             UpperCAmelCase_     					=				num_hidden_layers
             UpperCAmelCase_     					=				num_attention_heads
             UpperCAmelCase_     					=				intermediate_multiple_size
             UpperCAmelCase_     					=				hidden_act
             UpperCAmelCase_     					=				hidden_dropout
             UpperCAmelCase_     					=				attention_dropout
             UpperCAmelCase_     					=				weight_tying
             UpperCAmelCase_     					=				max_position_embeddings
             UpperCAmelCase_     					=				type_vocab_size
             UpperCAmelCase_     					=				type_sequence_label_size
             UpperCAmelCase_     					=				initializer_range
             UpperCAmelCase_     					=				num_labels
             UpperCAmelCase_     					=				num_choices
             UpperCAmelCase_     					=				scope



       def 	lowercase__							(				self     :    Union[str, Any]       )					->		Tuple:


             '''simple docstring'''




             UpperCAmelCase_     					=				ids_tensor([self.batch_size, self.seq_length]						,							self.vocab_size       )

             UpperCAmelCase_     					=				None
             if self.use_input_mask:
                   UpperCAmelCase_     					=				random_attention_mask([self.batch_size, self.seq_length]       )

             UpperCAmelCase_     					=				None
             if self.use_labels:
                   UpperCAmelCase_     					=				ids_tensor([self.batch_size, self.seq_length]						,							self.num_labels       )

             UpperCAmelCase_     					=				self.get_config()

             return config, input_ids, input_mask, token_labels



       def 	lowercase__							(				self     :    str       )					->		Tuple:


             '''simple docstring'''




             return GPTNeoXJapaneseConfig(
                 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_multiple_size=self.intermediate_multiple_size						,							hidden_act=self.hidden_act						,							hidden_dropout=self.hidden_dropout						,							attention_dropout=self.attention_dropout						,							weight_tying=self.weight_tying						,							max_position_embeddings=self.max_position_embeddings						,							type_vocab_size=self.type_vocab_size						,							is_decoder=_UpperCAmelCase						,							initializer_range=self.initializer_range						,							)



       def 	lowercase__							(				self     :    Tuple       )					->		Union[str, Any]:


             '''simple docstring'''




             UpperCAmelCase_					,       UpperCAmelCase_					,       UpperCAmelCase_					,       UpperCAmelCase_     					=				self.prepare_config_and_inputs()

             UpperCAmelCase_     					=				True

             return config, input_ids, input_mask, token_labels



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


             '''simple docstring'''




             UpperCAmelCase_     					=				GPTNeoXJapaneseModel(config=_UpperCAmelCase       )
             model.to(_UpperCAmelCase       )
             model.eval()
             UpperCAmelCase_     					=				model(_UpperCAmelCase						,							attention_mask=_UpperCAmelCase       )
             UpperCAmelCase_     					=				model(_UpperCAmelCase       )
             self.parent.assertEqual(result.last_hidden_state.shape						,							(self.batch_size, self.seq_length, self.hidden_size)       )



       def 	lowercase__							(				self     :    Optional[int]						,							_UpperCAmelCase     :    Tuple						,							_UpperCAmelCase     :    Dict						,							_UpperCAmelCase     :    str       )					->		int:


             '''simple docstring'''




             UpperCAmelCase_     					=				True
             UpperCAmelCase_     					=				GPTNeoXJapaneseModel(_UpperCAmelCase       )
             model.to(_UpperCAmelCase       )
             model.eval()
             UpperCAmelCase_     					=				model(_UpperCAmelCase						,							attention_mask=_UpperCAmelCase       )
             self.parent.assertEqual(result.last_hidden_state.shape						,							(self.batch_size, self.seq_length, self.hidden_size)       )



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


             '''simple docstring'''




             UpperCAmelCase_     					=				GPTNeoXJapaneseForCausalLM(config=_UpperCAmelCase       )
             model.to(_UpperCAmelCase       )
             model.eval()
             UpperCAmelCase_     					=				model(_UpperCAmelCase						,							attention_mask=_UpperCAmelCase						,							labels=_UpperCAmelCase       )
             self.parent.assertEqual(result.logits.shape						,							(self.batch_size, self.seq_length, self.vocab_size)       )



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


             '''simple docstring'''




             UpperCAmelCase_     					=				True
             UpperCAmelCase_     					=				GPTNeoXJapaneseForCausalLM(config=_UpperCAmelCase       )
             model.to(_UpperCAmelCase       )
             model.eval()

             # first forward pass
             UpperCAmelCase_     					=				model(_UpperCAmelCase						,							attention_mask=_UpperCAmelCase						,							use_cache=_UpperCAmelCase       )
             UpperCAmelCase_     					=				outputs.past_key_values

             # create hypothetical multiple next token and extent to next_input_ids
             UpperCAmelCase_     					=				ids_tensor((self.batch_size, 3)						,							config.vocab_size       )
             UpperCAmelCase_     					=				ids_tensor((self.batch_size, 3)						,							vocab_size=2       )

             # append to next input_ids and
             UpperCAmelCase_     					=				torch.cat([input_ids, next_tokens]						,							dim=-1       )
             UpperCAmelCase_     					=				torch.cat([input_mask, next_mask]						,							dim=-1       )

             UpperCAmelCase_     					=				model(_UpperCAmelCase						,							attention_mask=_UpperCAmelCase						,							output_hidden_states=_UpperCAmelCase       )
             UpperCAmelCase_     					=				output_from_no_past["hidden_states"][0]
             UpperCAmelCase_     					=				model(
                 _UpperCAmelCase						,							attention_mask=_UpperCAmelCase						,							past_key_values=_UpperCAmelCase						,							output_hidden_states=_UpperCAmelCase						,							)["hidden_states"][0]

             # select random slice
             UpperCAmelCase_     					=				ids_tensor((1,)						,							output_from_past.shape[-1]       ).item()
             UpperCAmelCase_     					=				output_from_no_past[:, -3:, random_slice_idx].detach()
             UpperCAmelCase_     					=				output_from_past[:, :, random_slice_idx].detach()

             self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]       )

             # test that outputs are equal for slice
             self.parent.assertTrue(torch.allclose(_UpperCAmelCase						,							_UpperCAmelCase						,							atol=1e-3       )       )







       def 	lowercase__							(				self     :    Union[str, Any]       )					->		Optional[int]:


             '''simple docstring'''




             UpperCAmelCase_     					=				self.prepare_config_and_inputs()
             UpperCAmelCase_					,       UpperCAmelCase_					,       UpperCAmelCase_					,       UpperCAmelCase_     					=				config_and_inputs
             UpperCAmelCase_     					=				{"input_ids": input_ids, "attention_mask": input_mask}
             return config, inputs_dict



@require_torch
class  lowercase__  (       SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE							,   unittest.TestCase ):







       '''simple docstring'''


       UpperCamelCase		=	(GPTNeoXJapaneseModel, GPTNeoXJapaneseForCausalLM) if is_torch_available() else ()
       UpperCamelCase		=	(GPTNeoXJapaneseForCausalLM,) if is_torch_available() else ()
       UpperCamelCase		=	(
           {'''feature-extraction''': GPTNeoXJapaneseModel, '''text-generation''': GPTNeoXJapaneseForCausalLM}
           if is_torch_available()
           else {}
       )
       UpperCamelCase		=	False
       UpperCamelCase		=	False
       UpperCamelCase		=	False
       UpperCamelCase		=	False



       def 	lowercase__							(				self     :    List[str]       )					->		Tuple:


             '''simple docstring'''




             UpperCAmelCase_     					=				GPTNeoXJapaneseModelTester(self       )
             UpperCAmelCase_     					=				ConfigTester(self						,							config_class=_UpperCAmelCase						,							hidden_size=37       )



       def 	lowercase__							(				self     :    Union[str, Any]       )					->		Optional[int]:


             '''simple docstring'''




             self.config_tester.run_common_tests()



       def 	lowercase__							(				self     :    List[str]       )					->		Union[str, Any]:


             '''simple docstring'''




             UpperCAmelCase_					,       UpperCAmelCase_					,       UpperCAmelCase_					,       UpperCAmelCase_     					=				self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_model(_UpperCAmelCase						,							_UpperCAmelCase						,							_UpperCAmelCase       )



       def 	lowercase__							(				self     :    List[str]       )					->		Union[str, Any]:


             '''simple docstring'''




             UpperCAmelCase_					,       UpperCAmelCase_					,       UpperCAmelCase_					,       UpperCAmelCase_     					=				self.model_tester.prepare_config_and_inputs_for_decoder()
             self.model_tester.create_and_check_model_as_decoder(_UpperCAmelCase						,							_UpperCAmelCase						,							_UpperCAmelCase       )



       def 	lowercase__							(				self     :    List[str]       )					->		Dict:


             '''simple docstring'''




             UpperCAmelCase_					,       UpperCAmelCase_					,       UpperCAmelCase_					,       UpperCAmelCase_     					=				self.model_tester.prepare_config_and_inputs_for_decoder()

             UpperCAmelCase_     					=				None

             self.model_tester.create_and_check_model_as_decoder(_UpperCAmelCase						,							_UpperCAmelCase						,							_UpperCAmelCase       )



       def 	lowercase__							(				self     :    List[Any]       )					->		Union[str, Any]:


             '''simple docstring'''




             UpperCAmelCase_					,       UpperCAmelCase_					,       UpperCAmelCase_					,       UpperCAmelCase_     					=				self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_decoder_model_past_large_inputs(_UpperCAmelCase						,							_UpperCAmelCase						,							_UpperCAmelCase       )



       def 	lowercase__							(				self     :    Dict       )					->		Any:


             '''simple docstring'''




             UpperCAmelCase_     					=				self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_causal_lm(*_UpperCAmelCase       )







       @slow
       def 	lowercase__							(				self     :    Tuple       )					->		int:


             '''simple docstring'''




             UpperCAmelCase_     					=				"abeja/gpt-neox-japanese-2.7b"

             UpperCAmelCase_     					=				["データサイエンティストとは、", "100年後に必要とされる会社は、", "フルリモートの環境で働くために必要なことは、", "国境の長いトンネルを抜けると", "美味しい日本食といえば、"]

             UpperCAmelCase_     					=				[
                 "データサイエンティストとは、データを分析し、ビジネスに役立つ知見を導き出す専門家のことです。",
                 "100年後に必要とされる会社は、「人」が中心の会社です。",
                 "フルリモートの環境で働くために必要なことは、「自分の時間をコントロールする」ことです。",
                 "国境の長いトンネルを抜けると、そこは雪国だった。",
                 "美味しい日本食といえば、やっぱりお寿司ですよね。",
             ]

             UpperCAmelCase_     					=				GPTNeoXJapaneseTokenizer.from_pretrained(_UpperCAmelCase       )
             UpperCAmelCase_     					=				GPTNeoXJapaneseForCausalLM.from_pretrained(_UpperCAmelCase       )

             UpperCAmelCase_     					=				[]
             for prompt in prompts:
                   UpperCAmelCase_     					=				tokenizer(_UpperCAmelCase						,							return_tensors="pt"       ).input_ids
                   UpperCAmelCase_     					=				model.generate(_UpperCAmelCase						,							max_length=50       )
                   UpperCAmelCase_     					=				tokenizer.batch_decode(_UpperCAmelCase						,							skip_special_tokens=_UpperCAmelCase       )
                   predicted_outputs += generated_string
             self.assertListEqual(_UpperCAmelCase						,							_UpperCAmelCase       )








'''simple docstring'''


import argparse
import datetime







def      snake_case_  (    SCREAMING_SNAKE_CASE__	):







				"""simple docstring"""





				_SCREAMING_SNAKE_CASE					:			Optional[int]							= {
				    """0""": """Sunday""",
				    """1""": """Monday""",
				    """2""": """Tuesday""",
				    """3""": """Wednesday""",
				    """4""": """Thursday""",
				    """5""": """Friday""",
				    """6""": """Saturday""",
				}

				_SCREAMING_SNAKE_CASE					:			Optional[int]							= {0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 0}

				# Validate
				if not 0 < len(SCREAMING_SNAKE_CASE__	) < 11:
								raise ValueError("""Must be 10 characters long"""	)

				# Get month
				_SCREAMING_SNAKE_CASE					:			int							= int(date_input[0] + date_input[1]	)
				# Validate
				if not 0 < m < 13:
								raise ValueError("""Month must be between 1 - 12"""	)

				_SCREAMING_SNAKE_CASE					:			str							= date_input[2]
				# Validate
				if sep_a not in ["-", "/"]:
								raise ValueError("""Date separator must be '-' or '/'"""	)

				# Get day
				_SCREAMING_SNAKE_CASE					:			int							= int(date_input[3] + date_input[4]	)
				# Validate
				if not 0 < d < 32:
								raise ValueError("""Date must be between 1 - 31"""	)

				# Get second separator
				_SCREAMING_SNAKE_CASE					:			str							= date_input[5]
				# Validate
				if sep_a not in ["-", "/"]:
								raise ValueError("""Date separator must be '-' or '/'"""	)

				# Get year
				_SCREAMING_SNAKE_CASE					:			int							= int(date_input[6] + date_input[7] + date_input[8] + date_input[9]	)
				# Arbitrary year range
				if not 45 < y < 8500:
								raise ValueError(
								    """Year out of range. There has to be some sort of limit...right?"""	)

				# Get datetime obj for validation
				_SCREAMING_SNAKE_CASE					:			Optional[int]							= datetime.date(int(SCREAMING_SNAKE_CASE__	)				, int(SCREAMING_SNAKE_CASE__	)				, int(SCREAMING_SNAKE_CASE__	)	)

				# Start math
				if m <= 2:
								_SCREAMING_SNAKE_CASE					:			Union[str, Any]							= y - 1
								_SCREAMING_SNAKE_CASE					:			Optional[int]							= m + 12
				# maths var
				_SCREAMING_SNAKE_CASE					:			int							= int(str(SCREAMING_SNAKE_CASE__	)[:2]	)
				_SCREAMING_SNAKE_CASE					:			int							= int(str(SCREAMING_SNAKE_CASE__	)[2:]	)
				_SCREAMING_SNAKE_CASE					:			int							= int(2.6 * m - 5.3_9	)
				_SCREAMING_SNAKE_CASE					:			int							= int(c / 4	)
				_SCREAMING_SNAKE_CASE					:			int							= int(k / 4	)
				_SCREAMING_SNAKE_CASE					:			int							= int(d + k	)
				_SCREAMING_SNAKE_CASE					:			int							= int(t + u + v + x	)
				_SCREAMING_SNAKE_CASE					:			int							= int(z - (2 * c)	)
				_SCREAMING_SNAKE_CASE					:			int							= round(w % 7	)
				# End math

				# Validate math
				if f != convert_datetime_days[dt_ck.weekday()]:
								raise AssertionError("""The date was evaluated incorrectly. Contact developer."""	)

				# Response
				_SCREAMING_SNAKE_CASE					:			str							= f"""Your date {date_input}, is a {days[str(SCREAMING_SNAKE_CASE__	)]}!"""
				return response


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				UpperCAmelCase_						:  Tuple				  =						argparse.ArgumentParser(
				    description=(
				        'Find out what day of the week nearly any date is or was. Enter '
				        'date as a string in the mm-dd-yyyy or mm/dd/yyyy format'
				    )
				)
				parser.add_argument(
				    'date_input', type=str, help='Date as a string (mm-dd-yyyy or mm/dd/yyyy)'
				)
				UpperCAmelCase_						:  List[Any]				  =						parser.parse_args()
				zeller(args.date_input)




