

import shutil
import tempfile
import unittest

import numpy as np
import pytest

from transformers.testing_utils import require_vision
from transformers.utils import is_vision_available


if is_vision_available():
					from PIL import Image

					from transformers import AutoProcessor, BlipaProcessor, BlipImageProcessor, GPTaTokenizer, PreTrainedTokenizerFast

@require_vision
class        __SCREAMING_SNAKE_CASE					(     unittest.TestCase       ):






							def 				_lowerCamelCase		(						self  ):
														UpperCamelCase__				     =			tempfile.mkdtemp()

														UpperCamelCase__				     =			BlipImageProcessor()
														UpperCamelCase__				     =			GPTaTokenizer.from_pretrained("""hf-internal-testing/tiny-random-GPT2Model"""  )

														UpperCamelCase__				     =			BlipaProcessor(UpperCamelCase__  , UpperCamelCase__  )

														processor.save_pretrained(self.tmpdirname  )






							def 				_lowerCamelCase		(						self  , **__lowerCAmelCase  ):
														return AutoProcessor.from_pretrained(self.tmpdirname  , **UpperCamelCase__  ).tokenizer






							def 				_lowerCamelCase		(						self  , **__lowerCAmelCase  ):
														return AutoProcessor.from_pretrained(self.tmpdirname  , **UpperCamelCase__  ).image_processor






							def 				_lowerCamelCase		(						self  ):
														shutil.rmtree(self.tmpdirname  )






							def 				_lowerCamelCase		(						self  ):
														UpperCamelCase__				     =			[np.random.randint(255  , size=(3, 30, 400)  , dtype=np.uinta  )]

														UpperCamelCase__				     =			[Image.fromarray(np.moveaxis(UpperCamelCase__  , 0  , -1  )  ) for x in image_inputs]

														return image_inputs






							def 				_lowerCamelCase		(						self  ):
														UpperCamelCase__				     =			BlipaProcessor(tokenizer=self.get_tokenizer()  , image_processor=self.get_image_processor()  )
														processor.save_pretrained(self.tmpdirname  )

														UpperCamelCase__				     =			self.get_tokenizer(bos_token="""(BOS)"""  , eos_token="""(EOS)"""  )
														UpperCamelCase__				     =			self.get_image_processor(do_normalize=UpperCamelCase__  , padding_value=1.0  )

														UpperCamelCase__				     =			BlipaProcessor.from_pretrained(
														    self.tmpdirname  , bos_token="""(BOS)"""  , eos_token="""(EOS)"""  , do_normalize=UpperCamelCase__  , padding_value=1.0  )

														self.assertEqual(processor.tokenizer.get_vocab()  , tokenizer_add_kwargs.get_vocab()  )
														self.assertIsInstance(processor.tokenizer  , UpperCamelCase__  )

														self.assertEqual(processor.image_processor.to_json_string()  , image_processor_add_kwargs.to_json_string()  )
														self.assertIsInstance(processor.image_processor  , UpperCamelCase__  )






							def 				_lowerCamelCase		(						self  ):
														UpperCamelCase__				     =			self.get_image_processor()
														UpperCamelCase__				     =			self.get_tokenizer()

														UpperCamelCase__				     =			BlipaProcessor(tokenizer=UpperCamelCase__  , image_processor=UpperCamelCase__  )

														UpperCamelCase__				     =			self.prepare_image_inputs()

														UpperCamelCase__				     =			image_processor(UpperCamelCase__  , return_tensors="""np"""  )
														UpperCamelCase__				     =			processor(images=UpperCamelCase__  , return_tensors="""np"""  )

														for key in input_feat_extract.keys():
																					self.assertAlmostEqual(input_feat_extract[key].sum()  , input_processor[key].sum()  , delta=1E-2  )






							def 				_lowerCamelCase		(						self  ):
														UpperCamelCase__				     =			self.get_image_processor()
														UpperCamelCase__				     =			self.get_tokenizer()

														UpperCamelCase__				     =			BlipaProcessor(tokenizer=UpperCamelCase__  , image_processor=UpperCamelCase__  )

														UpperCamelCase__				     =			"""lower newer"""

														UpperCamelCase__				     =			processor(text=UpperCamelCase__  )

														UpperCamelCase__				     =			tokenizer(UpperCamelCase__  , return_token_type_ids=UpperCamelCase__  )

														for key in encoded_tok.keys():
																					self.assertListEqual(encoded_tok[key]  , encoded_processor[key]  )






							def 				_lowerCamelCase		(						self  ):
														UpperCamelCase__				     =			self.get_image_processor()
														UpperCamelCase__				     =			self.get_tokenizer()

														UpperCamelCase__				     =			BlipaProcessor(tokenizer=UpperCamelCase__  , image_processor=UpperCamelCase__  )

														UpperCamelCase__				     =			"""lower newer"""
														UpperCamelCase__				     =			self.prepare_image_inputs()

														UpperCamelCase__				     =			processor(text=UpperCamelCase__  , images=UpperCamelCase__  )

														self.assertListEqual(list(inputs.keys()  )  , ["""pixel_values""", """input_ids""", """attention_mask"""]  )

														# test if it raises when no input is passed
														with pytest.raises(UpperCamelCase__  ):
																					processor()






							def 				_lowerCamelCase		(						self  ):
														UpperCamelCase__				     =			self.get_image_processor()
														UpperCamelCase__				     =			self.get_tokenizer()

														UpperCamelCase__				     =			BlipaProcessor(tokenizer=UpperCamelCase__  , image_processor=UpperCamelCase__  )

														UpperCamelCase__				     =			[[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

														UpperCamelCase__				     =			processor.batch_decode(UpperCamelCase__  )
														UpperCamelCase__				     =			tokenizer.batch_decode(UpperCamelCase__  )

														self.assertListEqual(UpperCamelCase__  , UpperCamelCase__  )







							def 				_lowerCamelCase		(						self  ):
														UpperCamelCase__				     =			self.get_image_processor()
														UpperCamelCase__				     =			self.get_tokenizer()

														UpperCamelCase__				     =			BlipaProcessor(tokenizer=UpperCamelCase__  , image_processor=UpperCamelCase__  )

														UpperCamelCase__				     =			"""lower newer"""
														UpperCamelCase__				     =			self.prepare_image_inputs()

														UpperCamelCase__				     =			processor(text=UpperCamelCase__  , images=UpperCamelCase__  )

														# For now the processor supports only ['pixel_values', 'input_ids', 'attention_mask']
														self.assertListEqual(list(inputs.keys()  )  , ["""pixel_values""", """input_ids""", """attention_mask"""]  )











import argparse
import datetime





def     _UpperCamelCase     (a__   :str       ):






							"""simple docstring"""





							UpperCamelCase__				     =			{
							    """0""": """Sunday""",
							    """1""": """Monday""",
							    """2""": """Tuesday""",
							    """3""": """Wednesday""",
							    """4""": """Thursday""",
							    """5""": """Friday""",
							    """6""": """Saturday""",
							}

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

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

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

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

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

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

							# Get year
							UpperCamelCase__				     =			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
							UpperCamelCase__				     =			datetime.date(int(a__       )   ,			int(a__       )   ,			int(a__       )       )

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


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					UpperCamelCase__											= 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__											= parser.parse_args()
					zeller(args.date_input)




