import copy
import os
from typing import TYPE_CHECKING, List, Union


if TYPE_CHECKING:
     pass

from ...configuration_utils import PretrainedConfig
from ...utils import logging


__magic_name__    		=logging.get_logger(__name__)

__magic_name__    		={
    '''kakaobrain/align-base''': '''https://huggingface.co/kakaobrain/align-base/resolve/main/config.json''',
}



class      _A (     __UpperCamelCase				):
  SCREAMING_SNAKE_CASE_						:						List[str]    ="align_text_model"






  def __init__(self ,					SCREAMING_SNAKE_CASE_=3_0522 ,					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_=2 ,					SCREAMING_SNAKE_CASE_=0.02 ,					SCREAMING_SNAKE_CASE_=1E-12 ,					SCREAMING_SNAKE_CASE_=0 ,					SCREAMING_SNAKE_CASE_="absolute" ,					SCREAMING_SNAKE_CASE_=True ,					**SCREAMING_SNAKE_CASE_ ,					)		->   Tuple:





       '''simple docstring'''





       super().__init__(**_lowercase						)

       UpperCamelCase__					    =   vocab_size
       UpperCamelCase__					    =   hidden_size
       UpperCamelCase__					    =   num_hidden_layers
       UpperCamelCase__					    =   num_attention_heads
       UpperCamelCase__					    =   hidden_act
       UpperCamelCase__					    =   intermediate_size
       UpperCamelCase__					    =   hidden_dropout_prob
       UpperCamelCase__					    =   attention_probs_dropout_prob
       UpperCamelCase__					    =   max_position_embeddings
       UpperCamelCase__					    =   type_vocab_size
       UpperCamelCase__					    =   initializer_range
       UpperCamelCase__					    =   layer_norm_eps
       UpperCamelCase__					    =   position_embedding_type
       UpperCamelCase__					    =   use_cache
       UpperCamelCase__					    =   pad_token_id






  @classmethod
  def 		_a       (cls ,					SCREAMING_SNAKE_CASE_ ,					**SCREAMING_SNAKE_CASE_						)		->   "PretrainedConfig":





       '''simple docstring'''





       cls._set_token_in_kwargs(_lowercase						)

       UpperCamelCase__    ,							UpperCamelCase__					    =   cls.get_config_dict(_lowercase ,					**_lowercase						)

       # get the text config dict if we are loading from AlignConfig
       if config_dict.get('''model_type'''						) == "align":
            UpperCamelCase__					    =   config_dict['''text_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(_lowercase ,					**_lowercase						)



class      _A (     __UpperCamelCase				):
  SCREAMING_SNAKE_CASE_						:						str    ="align_vision_model"






  def __init__(self ,					SCREAMING_SNAKE_CASE_ = 3 ,					SCREAMING_SNAKE_CASE_ = 600 ,					SCREAMING_SNAKE_CASE_ = 2.0 ,					SCREAMING_SNAKE_CASE_ = 3.1 ,					SCREAMING_SNAKE_CASE_ = 8 ,					SCREAMING_SNAKE_CASE_ = [3, 3, 5, 3, 5, 5, 3] ,					SCREAMING_SNAKE_CASE_ = [32, 16, 24, 40, 80, 112, 192] ,					SCREAMING_SNAKE_CASE_ = [16, 24, 40, 80, 112, 192, 320] ,					SCREAMING_SNAKE_CASE_ = [] ,					SCREAMING_SNAKE_CASE_ = [1, 2, 2, 2, 1, 2, 1] ,					SCREAMING_SNAKE_CASE_ = [1, 2, 2, 3, 3, 4, 1] ,					SCREAMING_SNAKE_CASE_ = [1, 6, 6, 6, 6, 6, 6] ,					SCREAMING_SNAKE_CASE_ = 0.25 ,					SCREAMING_SNAKE_CASE_ = "swish" ,					SCREAMING_SNAKE_CASE_ = 2560 ,					SCREAMING_SNAKE_CASE_ = "mean" ,					SCREAMING_SNAKE_CASE_ = 0.02 ,					SCREAMING_SNAKE_CASE_ = 0.001 ,					SCREAMING_SNAKE_CASE_ = 0.99 ,					SCREAMING_SNAKE_CASE_ = 0.2 ,					**SCREAMING_SNAKE_CASE_ ,					)		->   str:





       '''simple docstring'''





       super().__init__(**_lowercase						)

       UpperCamelCase__					    =   num_channels
       UpperCamelCase__					    =   image_size
       UpperCamelCase__					    =   width_coefficient
       UpperCamelCase__					    =   depth_coefficient
       UpperCamelCase__					    =   depth_divisor
       UpperCamelCase__					    =   kernel_sizes
       UpperCamelCase__					    =   in_channels
       UpperCamelCase__					    =   out_channels
       UpperCamelCase__					    =   depthwise_padding
       UpperCamelCase__					    =   strides
       UpperCamelCase__					    =   num_block_repeats
       UpperCamelCase__					    =   expand_ratios
       UpperCamelCase__					    =   squeeze_expansion_ratio
       UpperCamelCase__					    =   hidden_act
       UpperCamelCase__					    =   hidden_dim
       UpperCamelCase__					    =   pooling_type
       UpperCamelCase__					    =   initializer_range
       UpperCamelCase__					    =   batch_norm_eps
       UpperCamelCase__					    =   batch_norm_momentum
       UpperCamelCase__					    =   drop_connect_rate
       UpperCamelCase__					    =   sum(_lowercase						) * 4






  @classmethod
  def 		_a       (cls ,					SCREAMING_SNAKE_CASE_ ,					**SCREAMING_SNAKE_CASE_						)		->   "PretrainedConfig":





       '''simple docstring'''





       cls._set_token_in_kwargs(_lowercase						)

       UpperCamelCase__    ,							UpperCamelCase__					    =   cls.get_config_dict(_lowercase ,					**_lowercase						)

       # get the vision config dict if we are loading from AlignConfig
       if config_dict.get('''model_type'''						) == "align":
            UpperCamelCase__					    =   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(_lowercase ,					**_lowercase						)



class      _A (     __UpperCamelCase				):
  SCREAMING_SNAKE_CASE_						:						Union[str, Any]    ="align"
  SCREAMING_SNAKE_CASE_						:						Any    =True






  def __init__(self ,					SCREAMING_SNAKE_CASE_=None ,					SCREAMING_SNAKE_CASE_=None ,					SCREAMING_SNAKE_CASE_=640 ,					SCREAMING_SNAKE_CASE_=1.0 ,					SCREAMING_SNAKE_CASE_=0.02 ,					**SCREAMING_SNAKE_CASE_ ,					)		->   Dict:





       '''simple docstring'''





       super().__init__(**_lowercase						)

       if text_config is None:
            UpperCamelCase__					    =   {}
            logger.info('''text_config is None. Initializing the AlignTextConfig with default values.'''						)

       if vision_config is None:
            UpperCamelCase__					    =   {}
            logger.info('''vision_config is None. Initializing the AlignVisionConfig with default values.'''						)

       UpperCamelCase__					    =   AlignTextConfig(**_lowercase						)
       UpperCamelCase__					    =   AlignVisionConfig(**_lowercase						)

       UpperCamelCase__					    =   projection_dim
       UpperCamelCase__					    =   temperature_init_value
       UpperCamelCase__					    =   initializer_range






  @classmethod
  def 		_a       (cls ,					SCREAMING_SNAKE_CASE_ ,					SCREAMING_SNAKE_CASE_ ,					**SCREAMING_SNAKE_CASE_						)		->   Any:





       '''simple docstring'''





       return cls(text_config=text_config.to_dict() ,					vision_config=vision_config.to_dict() ,					**_lowercase						)






  def 		_a       (self						)		->   List[Any]:





       '''simple docstring'''





       UpperCamelCase__					    =   copy.deepcopy(self.__dict__						)
       UpperCamelCase__					    =   self.text_config.to_dict()
       UpperCamelCase__					    =   self.vision_config.to_dict()
       UpperCamelCase__					    =   self.__class__.model_type
       return output









'''simple docstring'''
def 			lowerCamelCase(							SCREAMING_SNAKE_CASE_       ,SCREAMING_SNAKE_CASE_     )		->		bool:
			A_									= len(SCREAMING_SNAKE_CASE_     ) + 1
			A_									= len(SCREAMING_SNAKE_CASE_     ) + 1

			# dp is a 2d matrix where dp[i][j] denotes whether prefix string of
			# length i of input_string matches with prefix string of length j of
			# given pattern.
			# "dp" stands for dynamic programming.
			A_									= [[0 for i in range(SCREAMING_SNAKE_CASE_     )] for j in range(SCREAMING_SNAKE_CASE_     )]

			# since string of zero length match pattern of zero length
			A_									= 1

			# since pattern of zero length will never match with string of non-zero length
			for i in range(1       ,SCREAMING_SNAKE_CASE_     ):
						A_									= 0

			# since string of zero length will match with pattern where there
			# is at least one * alternatively
			for j in range(1       ,SCREAMING_SNAKE_CASE_     ):
						A_									= dp[0][j - 2] if pattern[j - 1] == '*' else 0

			# now using bottom-up approach to find for all remaining lengths
			for i in range(1       ,SCREAMING_SNAKE_CASE_     ):
						for j in range(1       ,SCREAMING_SNAKE_CASE_     ):
									if input_string[i - 1] == pattern[j - 1] or pattern[j - 1] == ".":
												A_									= dp[i - 1][j - 1]

									elif pattern[j - 1] == "*":
												if dp[i][j - 2] == 1:
															A_									= 1
												elif pattern[j - 2] in (input_string[i - 1], "."):
															A_									= dp[i - 1][j]
												else:
															A_									= 0
									else:
												A_									= 0

			return bool(dp[-1][-1]     )


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							# inputing the strings
							# input_string = input("input a string :")
							# pattern = input("input a pattern :")

							_SCREAMING_SNAKE_CASE			=						"aab"
							_SCREAMING_SNAKE_CASE			=						"c*a*b"

							# using function to check whether given string matches the given pattern
							if match_pattern(input_string, pattern):
														print(f"""{input_string} matches the given pattern {pattern}""")
							else:
														print(f"""{input_string} does not match with the given pattern {pattern}""")




