'''simple docstring'''

import shutil
import tempfile
import unittest

import numpy as np

from transformers.testing_utils import (
    is_pt_tf_cross_test,
    require_tf,
    require_torch,
    require_torchvision,
    require_vision,
)
from transformers.utils import is_tf_available, is_torch_available, is_vision_available


if is_vision_available():
  from PIL import Image

  from transformers import AutoProcessor, SamImageProcessor, SamProcessor

if is_torch_available():
  import torch

if is_tf_available():
  import tensorflow as tf



@require_vision
@require_torchvision
class      UpperCAmelCase    (		unittest.TestCase   ):





       '''simple docstring'''



       def _lowerCAmelCase(		self					)    ->    List[str]:
        lowercase__							:       Union[str, Any]										=   tempfile.mkdtemp()
        lowercase__							:       Optional[int]										=   SamImageProcessor()
        lowercase__							:       str										=   SamProcessor(__A					)
        processor.save_pretrained(self.tmpdirname					)

       def _lowerCAmelCase(		self      ,  **__lowerCAmelCase					)    ->    List[str]:
        return AutoProcessor.from_pretrained(self.tmpdirname      ,  **__A					).image_processor

       def _lowerCAmelCase(		self					)    ->    List[Any]:
        shutil.rmtree(self.tmpdirname					)

       def _lowerCAmelCase(		self					)    ->    List[str]:
        lowercase__							:       List[str]										=   [np.random.randint(255      ,  size=(3, 30, 400)      ,  dtype=np.uinta					)]

        lowercase__							:       str										=   [Image.fromarray(np.moveaxis(__A      ,  0      ,  -1					)					) for x in image_inputs]

        return image_inputs

       def _lowerCAmelCase(		self					)    ->    Any:
        lowercase__							:       Any										=   SamProcessor(image_processor=self.get_image_processor()					)
        processor.save_pretrained(self.tmpdirname					)

        lowercase__							:       Optional[Any]										=   self.get_image_processor(do_normalize=__A      ,  padding_value=1.0					)

        lowercase__							:       List[Any]										=   SamProcessor.from_pretrained(self.tmpdirname      ,  do_normalize=__A      ,  padding_value=1.0					)

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

       def _lowerCAmelCase(		self					)    ->    List[str]:
        lowercase__							:       Union[str, Any]										=   self.get_image_processor()

        lowercase__							:       Tuple										=   SamProcessor(image_processor=__A					)

        lowercase__							:       Optional[int]										=   self.prepare_image_inputs()

        lowercase__							:       str										=   image_processor(__A      ,  return_tensors='''np'''					)
        lowercase__							:       List[str]										=   processor(images=__A      ,  return_tensors='''np'''					)

        input_feat_extract.pop('''original_sizes'''					)  # pop original_sizes as it is popped in the processor
        input_feat_extract.pop('''reshaped_input_sizes'''					)  # pop original_sizes as it is popped in the processor

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


       @require_torch
       def _lowerCAmelCase(		self					)    ->    Tuple:
        lowercase__							:       List[Any]										=   self.get_image_processor()

        lowercase__							:       List[Any]										=   SamProcessor(image_processor=__A					)
        lowercase__							:       Dict										=   [torch.ones((1, 3, 5, 5)					)]

        lowercase__							:       Dict										=   [[1764, 2646]]

        lowercase__							:       List[str]										=   [[683, 1024]]
        lowercase__							:       List[str]										=   processor.post_process_masks(__A      ,  __A      ,  __A					)
        self.assertEqual(masks[0].shape      ,  (1, 3, 1764, 2646)					)

        lowercase__							:       Optional[int]										=   processor.post_process_masks(
            __A      ,  torch.tensor(__A					)      ,  torch.tensor(__A					)					)
        self.assertEqual(masks[0].shape      ,  (1, 3, 1764, 2646)					)

        # should also work with np
        lowercase__							:       List[str]										=   [np.ones((1, 3, 5, 5)					)]
        lowercase__							:       Tuple										=   processor.post_process_masks(__A      ,  np.array(__A					)      ,  np.array(__A					)					)

        self.assertEqual(masks[0].shape      ,  (1, 3, 1764, 2646)					)

        lowercase__							:       Union[str, Any]										=   [[1, 0], [0, 1]]
        with self.assertRaises(__A					):
         lowercase__							:       Union[str, Any]										=   processor.post_process_masks(__A      ,  np.array(__A					)      ,  np.array(__A					)					)



@require_vision
@require_tf
class      UpperCAmelCase    (		unittest.TestCase   ):





       '''simple docstring'''



       def _lowerCAmelCase(		self					)    ->    Union[str, Any]:
        lowercase__							:       List[str]										=   tempfile.mkdtemp()
        lowercase__							:       str										=   SamImageProcessor()
        lowercase__							:       Dict										=   SamProcessor(__A					)
        processor.save_pretrained(self.tmpdirname					)

       def _lowerCAmelCase(		self      ,  **__lowerCAmelCase					)    ->    str:
        return AutoProcessor.from_pretrained(self.tmpdirname      ,  **__A					).image_processor

       def _lowerCAmelCase(		self					)    ->    List[str]:
        shutil.rmtree(self.tmpdirname					)

       def _lowerCAmelCase(		self					)    ->    Any:
        lowercase__							:       List[str]										=   [np.random.randint(255      ,  size=(3, 30, 400)      ,  dtype=np.uinta					)]

        lowercase__							:       List[str]										=   [Image.fromarray(np.moveaxis(__A      ,  0      ,  -1					)					) for x in image_inputs]

        return image_inputs

       def _lowerCAmelCase(		self					)    ->    List[str]:
        lowercase__							:       List[str]										=   SamProcessor(image_processor=self.get_image_processor()					)
        processor.save_pretrained(self.tmpdirname					)

        lowercase__							:       Optional[Any]										=   self.get_image_processor(do_normalize=__A      ,  padding_value=1.0					)

        lowercase__							:       Optional[int]										=   SamProcessor.from_pretrained(self.tmpdirname      ,  do_normalize=__A      ,  padding_value=1.0					)

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

       def _lowerCAmelCase(		self					)    ->    List[Any]:
        lowercase__							:       List[Any]										=   self.get_image_processor()

        lowercase__							:       int										=   SamProcessor(image_processor=__A					)

        lowercase__							:       Any										=   self.prepare_image_inputs()

        lowercase__							:       Optional[Any]										=   image_processor(__A      ,  return_tensors='''np'''					)
        lowercase__							:       Dict										=   processor(images=__A      ,  return_tensors='''np'''					)

        input_feat_extract.pop('''original_sizes'''					)  # pop original_sizes as it is popped in the processor
        input_feat_extract.pop('''reshaped_input_sizes'''					)  # pop reshaped_input_sizes as it is popped in the processor

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


       @require_tf
       def _lowerCAmelCase(		self					)    ->    Tuple:
        lowercase__							:       Optional[int]										=   self.get_image_processor()

        lowercase__							:       Optional[int]										=   SamProcessor(image_processor=__A					)
        lowercase__							:       Optional[Any]										=   [tf.ones((1, 3, 5, 5)					)]

        lowercase__							:       List[Any]										=   [[1764, 2646]]

        lowercase__							:       List[Any]										=   [[683, 1024]]
        lowercase__							:       Optional[int]										=   processor.post_process_masks(__A      ,  __A      ,  __A      ,  return_tensors='''tf'''					)
        self.assertEqual(masks[0].shape      ,  (1, 3, 1764, 2646)					)

        lowercase__							:       int										=   processor.post_process_masks(
            __A      ,  tf.convert_to_tensor(__A					)      ,  tf.convert_to_tensor(__A					)      ,  return_tensors='''tf'''      ,  )
        self.assertEqual(masks[0].shape      ,  (1, 3, 1764, 2646)					)

        # should also work with np
        lowercase__							:       str										=   [np.ones((1, 3, 5, 5)					)]
        lowercase__							:       Any										=   processor.post_process_masks(
            __A      ,  np.array(__A					)      ,  np.array(__A					)      ,  return_tensors='''tf'''					)

        self.assertEqual(masks[0].shape      ,  (1, 3, 1764, 2646)					)

        lowercase__							:       int										=   [[1, 0], [0, 1]]
        with self.assertRaises(tf.errors.InvalidArgumentError					):
         lowercase__							:       Optional[Any]										=   processor.post_process_masks(
             __A      ,  np.array(__A					)      ,  np.array(__A					)      ,  return_tensors='''tf'''					)



@require_vision
@require_torchvision
class      UpperCAmelCase    (		unittest.TestCase   ):





       '''simple docstring'''



       def _lowerCAmelCase(		self					)    ->    List[Any]:
        lowercase__							:       str										=   tempfile.mkdtemp()
        lowercase__							:       Union[str, Any]										=   SamImageProcessor()
        lowercase__							:       int										=   SamProcessor(__A					)
        processor.save_pretrained(self.tmpdirname					)

       def _lowerCAmelCase(		self      ,  **__lowerCAmelCase					)    ->    Union[str, Any]:
        return AutoProcessor.from_pretrained(self.tmpdirname      ,  **__A					).image_processor

       def _lowerCAmelCase(		self					)    ->    List[Any]:
        shutil.rmtree(self.tmpdirname					)

       def _lowerCAmelCase(		self					)    ->    Optional[int]:
        lowercase__							:       Any										=   [np.random.randint(255      ,  size=(3, 30, 400)      ,  dtype=np.uinta					)]

        lowercase__							:       str										=   [Image.fromarray(np.moveaxis(__A      ,  0      ,  -1					)					) for x in image_inputs]

        return image_inputs

       @is_pt_tf_cross_test
       def _lowerCAmelCase(		self					)    ->    int:
        lowercase__							:       List[Any]										=   self.get_image_processor()

        lowercase__							:       Tuple										=   SamProcessor(image_processor=__A					)
        lowercase__							:       Optional[int]										=   np.random.randint(0      ,  2      ,  size=(1, 3, 5, 5)					).astype(np.floataa					)
        lowercase__							:       List[str]										=   [tf.convert_to_tensor(__A					)]
        lowercase__							:       str										=   [torch.tensor(__A					)]

        lowercase__							:       Dict										=   [[1764, 2646]]

        lowercase__							:       str										=   [[683, 1024]]
        lowercase__							:       Union[str, Any]										=   processor.post_process_masks(
            __A      ,  __A      ,  __A      ,  return_tensors='''tf'''					)
        lowercase__							:       str										=   processor.post_process_masks(
            __A      ,  __A      ,  __A      ,  return_tensors='''pt'''					)

        self.assertTrue(np.all(tf_masks[0].numpy() == pt_masks[0].numpy()					)					)


       @is_pt_tf_cross_test
       def _lowerCAmelCase(		self					)    ->    Optional[Any]:
        lowercase__							:       List[Any]										=   self.get_image_processor()

        lowercase__							:       Any										=   SamProcessor(image_processor=__A					)

        lowercase__							:       Any										=   self.prepare_image_inputs()

        lowercase__							:       int										=   image_processor(__A      ,  return_tensors='''pt'''					)['''pixel_values'''].numpy()
        lowercase__							:       List[Any]										=   processor(images=__A      ,  return_tensors='''pt'''					)['''pixel_values'''].numpy()

        lowercase__							:       List[str]										=   image_processor(__A      ,  return_tensors='''tf'''					)['''pixel_values'''].numpy()
        lowercase__							:       List[str]										=   processor(images=__A      ,  return_tensors='''tf'''					)['''pixel_values'''].numpy()

        self.assertTrue(np.allclose(__A      ,  __A					)					)
        self.assertTrue(np.allclose(__A      ,  __A					)					)
        self.assertTrue(np.allclose(__A      ,  __A					)					)








import argparse
import datetime






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

		SCREAMING_SNAKE_CASE__								=   {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
		SCREAMING_SNAKE_CASE__								=   int(date_input[0] + date_input[1]     )
		# Validate
		if not 0 < m < 13:
				raise ValueError("""Month must be between 1 - 12"""     )

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

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

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

		# Get datetime obj for validation
		SCREAMING_SNAKE_CASE__								=   datetime.date(int(UpperCamelCase__     )       , int(UpperCamelCase__     )       , int(UpperCamelCase__     )     )

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


if __name__ == "__main__":
	import doctest

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