





import functools
import operator

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


__A							   =							logging.get_logger(__name__)

__A							   =							{
    "asapp/sew-d-tiny-100k": "https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json",
    # See all SEW-D models at https://huggingface.co/models?filter=sew-d
}



class   _SCREAMING_SNAKE_CASE		(      __SCREAMING_SNAKE_CASE       ):







 '''simple docstring'''
 lowercase_						=     "sew-d"

 def __init__(self							:  Optional[int]			,					UpperCAmelCase_							:  str=32			,					UpperCAmelCase_							:  str=768			,					UpperCAmelCase_							:  Any=12			,					UpperCAmelCase_							:  Optional[Any]=12			,					UpperCAmelCase_							:  Optional[Any]=3_072			,					UpperCAmelCase_							:  Tuple=2			,					UpperCAmelCase_							:  List[Any]=512			,					UpperCAmelCase_							:  Union[str, Any]=256			,					UpperCAmelCase_							:  int=True			,					UpperCAmelCase_							:  List[Any]=True			,					UpperCAmelCase_							:  int=("p2c", "c2p")			,					UpperCAmelCase_							:  Tuple="layer_norm"			,					UpperCAmelCase_							:  Any="gelu_python"			,					UpperCAmelCase_							:  Tuple=0.1			,					UpperCAmelCase_							:  Any=0.1			,					UpperCAmelCase_							:  Optional[Any]=0.1			,					UpperCAmelCase_							:  List[Any]=0.0			,					UpperCAmelCase_							:  Dict=0.1			,					UpperCAmelCase_							:  int=0.02			,					UpperCAmelCase_							:  List[str]=1E-7			,					UpperCAmelCase_							:  List[Any]=1E-5			,					UpperCAmelCase_							:  Union[str, Any]="group"			,					UpperCAmelCase_							:  List[Any]="gelu"			,					UpperCAmelCase_							:  Any=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)			,					UpperCAmelCase_							:  str=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)			,					UpperCAmelCase_							:  Optional[Any]=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)			,					UpperCAmelCase_							:  Optional[Any]=False			,					UpperCAmelCase_							:  Tuple=128			,					UpperCAmelCase_							:  Optional[int]=16			,					UpperCAmelCase_							:  int=True			,					UpperCAmelCase_							:  Tuple=0.05			,					UpperCAmelCase_							:  Union[str, Any]=10			,					UpperCAmelCase_							:  int=2			,					UpperCAmelCase_							:  List[Any]=0.0			,					UpperCAmelCase_							:  Any=10			,					UpperCAmelCase_							:  Union[str, Any]=0			,					UpperCAmelCase_							:  List[str]="mean"			,					UpperCAmelCase_							:  Dict=False			,					UpperCAmelCase_							:  Optional[int]=False			,					UpperCAmelCase_							:  Dict=256			,					UpperCAmelCase_							:  Union[str, Any]=0			,					UpperCAmelCase_							:  Tuple=1			,					UpperCAmelCase_							:  int=2			,					**UpperCAmelCase_							:  Tuple			,					)			->str:



   '''simple docstring'''



   super().__init__(**UpperCAmelCase_			,					pad_token_id=UpperCAmelCase_			,					bos_token_id=UpperCAmelCase_			,					eos_token_id=UpperCAmelCase_)
   lowerCamelCase__: str         =hidden_size
   lowerCamelCase__: int         =feat_extract_norm
   lowerCamelCase__: str         =feat_extract_activation
   lowerCamelCase__: List[Any]         =list(UpperCAmelCase_)
   lowerCamelCase__: Dict         =list(UpperCAmelCase_)
   lowerCamelCase__: Tuple         =list(UpperCAmelCase_)
   lowerCamelCase__: str         =conv_bias
   lowerCamelCase__: Any         =num_conv_pos_embeddings
   lowerCamelCase__: List[Any]         =num_conv_pos_embedding_groups
   lowerCamelCase__: Optional[int]         =len(self.conv_dim)
   lowerCamelCase__: Tuple         =num_hidden_layers
   lowerCamelCase__: Tuple         =intermediate_size
   lowerCamelCase__: Optional[Any]         =squeeze_factor
   lowerCamelCase__: int         =max_position_embeddings
   lowerCamelCase__: Dict         =position_buckets
   lowerCamelCase__: List[Any]         =share_att_key
   lowerCamelCase__: Optional[Any]         =relative_attention
   lowerCamelCase__: List[str]         =norm_rel_ebd
   lowerCamelCase__: List[Any]         =list(UpperCAmelCase_)
   lowerCamelCase__: Optional[int]         =hidden_act
   lowerCamelCase__: str         =num_attention_heads
   lowerCamelCase__: str         =hidden_dropout
   lowerCamelCase__: List[str]         =attention_dropout
   lowerCamelCase__: str         =activation_dropout
   lowerCamelCase__: int         =feat_proj_dropout
   lowerCamelCase__: Tuple         =final_dropout
   lowerCamelCase__: Any         =layer_norm_eps
   lowerCamelCase__: Optional[Any]         =feature_layer_norm_eps
   lowerCamelCase__: Dict         =initializer_range
   lowerCamelCase__: int         =vocab_size

   if (
       (len(self.conv_stride) != self.num_feat_extract_layers)
       or (len(self.conv_kernel) != self.num_feat_extract_layers)
       or (len(self.conv_dim) != self.num_feat_extract_layers)
   ):
     raise ValueError(
         "Configuration for convolutional layers is incorrect."
         "It is required that `len(config.conv_dim)` == `len(config.conv_stride)` == `len(config.conv_kernel)`,"
         F"""but is `len(config.conv_dim) = {len(self.conv_dim)}`, `len(config.conv_stride)"""
         F"""= {len(self.conv_stride)}`, `len(config.conv_kernel) = {len(self.conv_kernel)}`.""")

   # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
   lowerCamelCase__: Any         =apply_spec_augment
   lowerCamelCase__: List[Any]         =mask_time_prob
   lowerCamelCase__: Optional[int]         =mask_time_length
   lowerCamelCase__: Optional[Any]         =mask_time_min_masks
   lowerCamelCase__: Tuple         =mask_feature_prob
   lowerCamelCase__: int         =mask_feature_length
   lowerCamelCase__: Optional[int]         =mask_feature_min_masks

   # ctc loss
   lowerCamelCase__: Dict         =ctc_loss_reduction
   lowerCamelCase__: Any         =ctc_zero_infinity

   # sequence classification
   lowerCamelCase__: Any         =use_weighted_layer_sum
   lowerCamelCase__: Optional[Any]         =classifier_proj_size







 @property
 def 				SCREAMING_SNAKE_CASE_   (self							:  Optional[int])			->Optional[Any]:



   '''simple docstring'''



   return functools.reduce(operator.mul			,					self.conv_stride			,					1)








"""simple docstring"""





class 						lowercase   :





      def __init__(			self					)						->	Any:
            lowerCAmelCase    		=			""""""
            lowerCAmelCase    		=			""""""
            lowerCAmelCase    		=			[]





      def        _snake_case     (			self ,		lowercase ,		lowercase					)						->	int:
            if m == -1:
                  return n + 1
            elif n == -1:
                  return m + 1
            elif self.dp[m][n] > -1:
                  return self.dp[m][n]
            else:
                  if self.worda[m] == self.worda[n]:
                        lowerCAmelCase    		=			self.__min_dist_top_down_dp(m - 1 ,		n - 1					)
                  else:
                        lowerCAmelCase    		=			self.__min_dist_top_down_dp(lowercase ,		n - 1					)
                        lowerCAmelCase    		=			self.__min_dist_top_down_dp(m - 1 ,		lowercase					)
                        lowerCAmelCase    		=			self.__min_dist_top_down_dp(m - 1 ,		n - 1					)
                        lowerCAmelCase    		=			1 + min(lowercase ,		lowercase ,		lowercase					)

                  return self.dp[m][n]





      def        _snake_case     (			self ,		lowercase ,		lowercase					)						->	int:
            lowerCAmelCase    		=			worda
            lowerCAmelCase    		=			worda
            lowerCAmelCase    		=			[[-1 for _ in range(len(lowercase					)					)] for _ in range(len(lowercase					)					)]

            return self.__min_dist_top_down_dp(len(lowercase					) - 1 ,		len(lowercase					) - 1					)





      def        _snake_case     (			self ,		lowercase ,		lowercase					)						->	int:
            lowerCAmelCase    		=			worda
            lowerCAmelCase    		=			worda
            lowerCAmelCase    		=			len(lowercase					)
            lowerCAmelCase    		=			len(lowercase					)
            lowerCAmelCase    		=			[[0 for _ in range(n + 1					)] for _ in range(m + 1					)]

            for i in range(m + 1					):
                  for j in range(n + 1					):
                        if i == 0:  # first string is empty
                              lowerCAmelCase    		=			j
                        elif j == 0:  # second string is empty
                              lowerCAmelCase    		=			i
                        elif worda[i - 1] == worda[j - 1]:  # last characters are equal
                              lowerCAmelCase    		=			self.dp[i - 1][j - 1]
                        else:
                              lowerCAmelCase    		=			self.dp[i][j - 1]
                              lowerCAmelCase    		=			self.dp[i - 1][j]
                              lowerCAmelCase    		=			self.dp[i - 1][j - 1]
                              lowerCAmelCase    		=			1 + min(lowercase ,		lowercase ,		lowercase					)
            return self.dp[m][n]


if __name__ == "__main__":
       SCREAMING_SNAKE_CASE__   =  EditDistance()

       print("****************** Testing Edit Distance DP Algorithm ******************")
       print()

       SCREAMING_SNAKE_CASE__   =  input("Enter the first string: ").strip()
       SCREAMING_SNAKE_CASE__   =  input("Enter the second string: ").strip()

       print()
       print(f'The minimum edit distance is: {solver.min_dist_top_down(Sa, Sa)}')
       print(f'The minimum edit distance is: {solver.min_dist_bottom_up(Sa, Sa)}')
       print()
       print("*************** End of Testing Edit Distance DP Algorithm ***************")






