



"""simple docstring"""







import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
from ...utils import logging
from ..auto import CONFIG_MAPPING


UpperCamelCase     =							logging.get_logger(__name__)

UpperCamelCase     =							{
    """salesforce/blip2-opt-2.7b""": """https://huggingface.co/salesforce/blip2-opt-2.7b/resolve/main/config.json""",
}






class       UpperCamelCase__			(   _lowerCAmelCase      ):

			"""simple docstring"""


			A__	:					Optional[int]							  =     "blip_2_vision_model"


			def __init__(      self						,	SCREAMING_SNAKE_CASE__=1408						,	SCREAMING_SNAKE_CASE__=6144						,	SCREAMING_SNAKE_CASE__=39						,	SCREAMING_SNAKE_CASE__=16						,	SCREAMING_SNAKE_CASE__=224						,	SCREAMING_SNAKE_CASE__=14						,	SCREAMING_SNAKE_CASE__="gelu"						,	SCREAMING_SNAKE_CASE__=0.0_0_0_0_1						,	SCREAMING_SNAKE_CASE__=0.0						,	SCREAMING_SNAKE_CASE__=1e-10						,	SCREAMING_SNAKE_CASE__=True						,	**SCREAMING_SNAKE_CASE__						,	)      ->	Optional[Any]:
				super().__init__(**SCREAMING_SNAKE_CASE__		)

				A__											=					hidden_size
				A__											=					intermediate_size
				A__											=					num_hidden_layers
				A__											=					num_attention_heads
				A__											=					patch_size
				A__											=					image_size
				A__											=					initializer_range
				A__											=					attention_dropout
				A__											=					layer_norm_eps
				A__											=					hidden_act
				A__											=					qkv_bias







			@classmethod
			def   snake_case__	(      cls						,	SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)      ->	"PretrainedConfig":
				cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__		)

				A__							,							A__											=					cls.get_config_dict(SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)

				# get the vision config dict if we are loading from Blip2Config
				if config_dict.get("model_type"		) == "blip-2":
					A__											=					config_dict["vision_config"]

				if "model_type" in config_dict and hasattr(cls						,	"model_type"		) and config_dict["model_type"] != cls.model_type:
					logger.warning(
					    f"""You are using a model of type {config_dict['model_type']} to instantiate a model of type """
					    f"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""		)

				return cls.from_dict(SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)






class       UpperCamelCase__			(   _lowerCAmelCase      ):

			"""simple docstring"""


			A__	:					List[Any]							  =     "blip_2_qformer"


			def __init__(      self						,	SCREAMING_SNAKE_CASE__=30522						,	SCREAMING_SNAKE_CASE__=768						,	SCREAMING_SNAKE_CASE__=12						,	SCREAMING_SNAKE_CASE__=12						,	SCREAMING_SNAKE_CASE__=3072						,	SCREAMING_SNAKE_CASE__="gelu"						,	SCREAMING_SNAKE_CASE__=0.1						,	SCREAMING_SNAKE_CASE__=0.1						,	SCREAMING_SNAKE_CASE__=512						,	SCREAMING_SNAKE_CASE__=0.0_2						,	SCREAMING_SNAKE_CASE__=1e-12						,	SCREAMING_SNAKE_CASE__=0						,	SCREAMING_SNAKE_CASE__="absolute"						,	SCREAMING_SNAKE_CASE__=2						,	SCREAMING_SNAKE_CASE__=1408						,	**SCREAMING_SNAKE_CASE__						,	)      ->	List[Any]:
				super().__init__(pad_token_id=SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)

				A__											=					vocab_size
				A__											=					hidden_size
				A__											=					num_hidden_layers
				A__											=					num_attention_heads
				A__											=					hidden_act
				A__											=					intermediate_size
				A__											=					hidden_dropout_prob
				A__											=					attention_probs_dropout_prob
				A__											=					max_position_embeddings
				A__											=					initializer_range
				A__											=					layer_norm_eps
				A__											=					position_embedding_type
				A__											=					cross_attention_frequency
				A__											=					encoder_hidden_size







			@classmethod
			def   snake_case__	(      cls						,	SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)      ->	"PretrainedConfig":
				cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__		)

				A__							,							A__											=					cls.get_config_dict(SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)

				# get the qformer config dict if we are loading from Blip2Config
				if config_dict.get("model_type"		) == "blip-2":
					A__											=					config_dict["qformer_config"]

				if "model_type" in config_dict and hasattr(cls						,	"model_type"		) and config_dict["model_type"] != cls.model_type:
					logger.warning(
					    f"""You are using a model of type {config_dict['model_type']} to instantiate a model of type """
					    f"""{cls.model_type}. This is not supported for all configurations of models and can yield errors."""		)

				return cls.from_dict(SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)






class       UpperCamelCase__			(   _lowerCAmelCase      ):

			"""simple docstring"""


			A__	:					Tuple							  =     "blip-2"
			A__	:					Optional[Any]							  =     True


			def __init__(      self						,	SCREAMING_SNAKE_CASE__=None						,	SCREAMING_SNAKE_CASE__=None						,	SCREAMING_SNAKE_CASE__=None						,	SCREAMING_SNAKE_CASE__=32						,	**SCREAMING_SNAKE_CASE__		)      ->	List[Any]:
				super().__init__(**SCREAMING_SNAKE_CASE__		)

				if vision_config is None:
					A__											=					{}
					logger.info("vision_config is None. initializing the Blip2VisionConfig with default values."		)

				if qformer_config is None:
					A__											=					{}
					logger.info("qformer_config is None. Initializing the Blip2QFormerConfig with default values."		)

				if text_config is None:
					A__											=					{}
					logger.info("text_config is None. Initializing the text config with default values (`OPTConfig`)."		)

				A__											=					BlipaVisionConfig(**SCREAMING_SNAKE_CASE__		)
				A__											=					BlipaQFormerConfig(**SCREAMING_SNAKE_CASE__		)
				A__											=					text_config["model_type"] if "model_type" in text_config else "opt"
				A__											=					CONFIG_MAPPING[text_model_type](**SCREAMING_SNAKE_CASE__		)

				A__											=					self.text_config.tie_word_embeddings
				A__											=					self.text_config.is_encoder_decoder

				A__											=					num_query_tokens
				A__											=					self.vision_config.hidden_size
				A__											=					self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
				A__											=					1.0
				A__											=					0.0_2


			@classmethod
			def   snake_case__	(      cls						,	SCREAMING_SNAKE_CASE__						,	SCREAMING_SNAKE_CASE__						,	SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__						,	)      ->	Union[str, Any]:
				return cls(
				    vision_config=vision_config.to_dict()						,	qformer_config=qformer_config.to_dict()						,	text_config=text_config.to_dict()						,	**SCREAMING_SNAKE_CASE__						,	)







			def   snake_case__	(      self		)      ->	List[Any]:
				A__											=					copy.deepcopy(self.__dict__		)
				A__											=					self.vision_config.to_dict()
				A__											=					self.qformer_config.to_dict()
				A__											=					self.text_config.to_dict()
				A__											=					self.__class__.model_type
				return output








'''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)




