


"""simple docstring"""


import argparse
import datetime




def   snake_case		(     UpperCamelCase__       :						str    )   ->      str:
      lowerCamelCase					:					Any        =	{
          """0""": """Sunday""",
          """1""": """Monday""",
          """2""": """Tuesday""",
          """3""": """Wednesday""",
          """4""": """Thursday""",
          """5""": """Friday""",
          """6""": """Saturday""",
      }

      lowerCamelCase					:					Any        =	{0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 0}

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

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

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

      # Get day
      lowerCamelCase					:					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
      lowerCamelCase					:					str        =	date_input[5]
      # Validate
      if sep_a not in ["-", "/"]:
            raise ValueError("""Date separator must be '-' or '/'"""    )

      # Get year
      lowerCamelCase					:					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
      lowerCamelCase					:					List[Any]        =	datetime.date(int(UpperCamelCase__    )			,				int(UpperCamelCase__    )			,				int(UpperCamelCase__    )    )

      # Start math
      if m <= 2:
            lowerCamelCase					:					Optional[int]        =	y - 1
            lowerCamelCase					:					int        =	m + 12
      # maths var
      lowerCamelCase					:					int        =	int(str(UpperCamelCase__    )[:2]    )
      lowerCamelCase					:					int        =	int(str(UpperCamelCase__    )[2:]    )
      lowerCamelCase					:					int        =	int(2.6 * m - 5.3_9    )
      lowerCamelCase					:					int        =	int(c / 4    )
      lowerCamelCase					:					int        =	int(k / 4    )
      lowerCamelCase					:					int        =	int(d + k    )
      lowerCamelCase					:					int        =	int(t + u + v + x    )
      lowerCamelCase					:					int        =	int(z - (2 * c)    )
      lowerCamelCase					:					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
      lowerCamelCase					:					str        =	F'Your date {date_input}, is a {days[str(UpperCamelCase__    )]}!'
      return response


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    __lowerCamelCase      :List[str]	    =		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)'
    )
    __lowerCamelCase      :Dict	    =		parser.parse_args()
    zeller(args.date_input)






"""simple docstring"""


import unittest
from pathlib import Path
from tempfile import NamedTemporaryFile, TemporaryDirectory

from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline
from transformers.convert_graph_to_onnx import (
    convert,
    ensure_valid_input,
    generate_identified_filename,
    infer_shapes,
    quantize,
)
from transformers.testing_utils import require_tf, require_tokenizers, require_torch, slow


class 			A__	:


     """simple docstring"""

     def 		a__						(	self:						Optional[int]     ,		__a:						Optional[int]     ,		__a:						Tuple     ,		__a:						Optional[int]	)->    List[str]:
           return None


class 			A__	:


     """simple docstring"""

     def 		a__						(	self:						Optional[int]     ,		__a:						Tuple     ,		__a:						str     ,		__a:						str     ,		__a:						str	)->    Tuple:
           return None


class 			A__	(						unittest.TestCase):


     """simple docstring"""
     snake_case__	:					Optional[Any]													=[
         # (model_name, model_kwargs)
         ('''bert-base-cased''', {}),
         ('''gpt2''', {'''use_cache''': False}),  # We don't support exporting GPT2 past keys anymore
     ]

     @require_tf
     @slow
     def 		a__						(	self:						Optional[Any]	)->    int:
           for model, model_kwargs in OnnxExportTestCase.MODEL_TO_TEST:
                 self._test_export(__a     ,		"""tf"""     ,		12     ,		**__a	)

     @require_torch
     @slow
     def 		a__						(	self:						str	)->    int:
           for model, model_kwargs in OnnxExportTestCase.MODEL_TO_TEST:
                 self._test_export(__a     ,		"""pt"""     ,		12     ,		**__a	)

     @require_torch
     @slow
     def 		a__						(	self:						Union[str, Any]	)->    Dict:
           from transformers import BertModel

           lowerCamelCase					:					int        =	["""[UNK]""", """[SEP]""", """[CLS]""", """[PAD]""", """[MASK]""", """some""", """other""", """words"""]
           with NamedTemporaryFile(mode="""w+t"""	) as vocab_file:
                 vocab_file.write("""\n""".join(__a	)	)
                 vocab_file.flush()
                 lowerCamelCase					:					Dict        =	BertTokenizerFast(vocab_file.name	)

           with TemporaryDirectory() as bert_save_dir:
                 lowerCamelCase					:					List[str]        =	BertModel(BertConfig(vocab_size=len(__a	)	)	)
                 model.save_pretrained(__a	)
                 self._test_export(__a     ,		"""pt"""     ,		12     ,		__a	)

     @require_tf
     @slow
     def 		a__						(	self:						Optional[Any]	)->    Optional[int]:
           for model, model_kwargs in OnnxExportTestCase.MODEL_TO_TEST:
                 lowerCamelCase					:					Optional[int]        =	self._test_export(__a     ,		"""tf"""     ,		12     ,		**__a	)
                 lowerCamelCase					:					Tuple        =	quantize(Path(__a	)	)

                 # Ensure the actual quantized model is not bigger than the original one
                 if quantized_path.stat().st_size >= Path(__a	).stat().st_size:
                       self.fail("""Quantized model is bigger than initial ONNX model"""	)

     @require_torch
     @slow
     def 		a__						(	self:						Any	)->    Optional[int]:
           for model, model_kwargs in OnnxExportTestCase.MODEL_TO_TEST:
                 lowerCamelCase					:					Any        =	self._test_export(__a     ,		"""pt"""     ,		12     ,		**__a	)
                 lowerCamelCase					:					Dict        =	quantize(__a	)

                 # Ensure the actual quantized model is not bigger than the original one
                 if quantized_path.stat().st_size >= Path(__a	).stat().st_size:
                       self.fail("""Quantized model is bigger than initial ONNX model"""	)

     def 		a__						(	self:						List[Any]     ,		__a:						Optional[Any]     ,		__a:						List[Any]     ,		__a:						Union[str, Any]     ,		__a:						Optional[Any]=None     ,		**__a:						Optional[int]	)->    Any:
           try:
                 # Compute path
                 with TemporaryDirectory() as tempdir:
                       lowerCamelCase					:					Optional[Any]        =	Path(__a	).joinpath("""model.onnx"""	)

                 # Remove folder if exists
                 if path.parent.exists():
                       path.parent.rmdir()

                 # Export
                 convert(__a     ,		__a     ,		__a     ,		__a     ,		__a     ,		**__a	)

                 return path
           except Exception as e:
                 self.fail(__a	)

     @require_torch
     @require_tokenizers
     @slow
     def 		a__						(	self:						Tuple	)->    Dict:
           from transformers import BertModel

           lowerCamelCase					:					int        =	BertModel(BertConfig.from_pretrained("""lysandre/tiny-bert-random"""	)	)
           lowerCamelCase					:					List[Any]        =	BertTokenizerFast.from_pretrained("""lysandre/tiny-bert-random"""	)
           self._test_infer_dynamic_axis(__a     ,		__a     ,		"""pt"""	)

     @require_tf
     @require_tokenizers
     @slow
     def 		a__						(	self:						Optional[Any]	)->    List[Any]:
           from transformers import TFBertModel

           lowerCamelCase					:					Union[str, Any]        =	TFBertModel(BertConfig.from_pretrained("""lysandre/tiny-bert-random"""	)	)
           lowerCamelCase					:					str        =	BertTokenizerFast.from_pretrained("""lysandre/tiny-bert-random"""	)
           self._test_infer_dynamic_axis(__a     ,		__a     ,		"""tf"""	)

     def 		a__						(	self:						List[str]     ,		__a:						str     ,		__a:						Optional[Any]     ,		__a:						str	)->    List[Any]:
           lowerCamelCase					:					List[str]        =	FeatureExtractionPipeline(__a     ,		__a	)

           lowerCamelCase					:					List[str]        =	["""input_ids""", """token_type_ids""", """attention_mask""", """output_0""", """output_1"""]
           lowerCamelCase     ,			lowerCamelCase     ,			lowerCamelCase     ,			lowerCamelCase					:					Tuple        =	infer_shapes(__a     ,		__a	)

           # Assert all variables are present
           self.assertEqual(len(__a	)     ,		len(__a	)	)
           self.assertTrue(all(var_name in shapes for var_name in variable_names	)	)
           self.assertSequenceEqual(variable_names[:3]     ,		__a	)
           self.assertSequenceEqual(variable_names[3:]     ,		__a	)

           # Assert inputs are {0: batch, 1: sequence}
           for var_name in ["input_ids", "token_type_ids", "attention_mask"]:
                 self.assertDictEqual(shapes[var_name]     ,		{0: """batch""", 1: """sequence"""}	)

           # Assert outputs are {0: batch, 1: sequence} and {0: batch}
           self.assertDictEqual(shapes["""output_0"""]     ,		{0: """batch""", 1: """sequence"""}	)
           self.assertDictEqual(shapes["""output_1"""]     ,		{0: """batch"""}	)

     def 		a__						(	self:						List[Any]	)->    int:
           lowerCamelCase					:					List[str]        =	["""input_ids""", """attention_mask""", """token_type_ids"""]
           lowerCamelCase					:					str        =	{"""input_ids""": [1, 2, 3, 4], """attention_mask""": [0, 0, 0, 0], """token_type_ids""": [1, 1, 1, 1]}
           lowerCamelCase     ,			lowerCamelCase					:					List[Any]        =	ensure_valid_input(FuncContiguousArgs()     ,		__a     ,		__a	)

           # Should have exactly the same number of args (all are valid)
           self.assertEqual(len(__a	)     ,		3	)

           # Should have exactly the same input names
           self.assertEqual(set(__a	)     ,		set(__a	)	)

           # Parameter should be reordered according to their respective place in the function:
           # (input_ids, token_type_ids, attention_mask)
           self.assertEqual(__a     ,		(tokens["""input_ids"""], tokens["""token_type_ids"""], tokens["""attention_mask"""])	)

           # Generated args are interleaved with another args (for instance parameter "past" in GPT2)
           lowerCamelCase     ,			lowerCamelCase					:					List[Any]        =	ensure_valid_input(FuncNonContiguousArgs()     ,		__a     ,		__a	)

           # Should have exactly the one arg (all before the one not provided "some_other_args")
           self.assertEqual(len(__a	)     ,		1	)
           self.assertEqual(len(__a	)     ,		1	)

           # Should have only "input_ids"
           self.assertEqual(inputs_args[0]     ,		tokens["""input_ids"""]	)
           self.assertEqual(ordered_input_names[0]     ,		"""input_ids"""	)







     def 		a__						(	self:						Tuple	)->    Tuple:
           lowerCamelCase					:					Optional[int]        =	generate_identified_filename(Path("""/home/something/my_fake_model.onnx"""	)     ,		"""-test"""	)
           self.assertEqual("""/home/something/my_fake_model-test.onnx"""     ,		generated.as_posix()	)




