
'''simple docstring'''





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_lxmert import LxmertTokenizer


lowerCamelCase      ={"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"}

lowerCamelCase      ={
    "vocab_file": {
        "unc-nlp/lxmert-base-uncased": "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/vocab.txt",
    },
    "tokenizer_file": {
        "unc-nlp/lxmert-base-uncased": (
            "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/tokenizer.json"
        ),
    },
}

lowerCamelCase      ={
    "unc-nlp/lxmert-base-uncased": 5_1_2,
}

lowerCamelCase      ={
    "unc-nlp/lxmert-base-uncased": {"do_lower_case": True},
}




class 				_lowerCamelCase (      _snake_case ):





     """simple docstring"""







     SCREAMING_SNAKE_CASE_		   =  VOCAB_FILES_NAMES
     SCREAMING_SNAKE_CASE_		   =  PRETRAINED_VOCAB_FILES_MAP
     SCREAMING_SNAKE_CASE_		   =  PRETRAINED_INIT_CONFIGURATION
     SCREAMING_SNAKE_CASE_		   =  PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
     SCREAMING_SNAKE_CASE_		   =  LxmertTokenizer






     def __init__(							self						,						__SCREAMING_SNAKE_CASE=None						,						__SCREAMING_SNAKE_CASE=None						,						__SCREAMING_SNAKE_CASE=True						,						__SCREAMING_SNAKE_CASE="[UNK]"						,						__SCREAMING_SNAKE_CASE="[SEP]"						,						__SCREAMING_SNAKE_CASE="[PAD]"						,						__SCREAMING_SNAKE_CASE="[CLS]"						,						__SCREAMING_SNAKE_CASE="[MASK]"						,						__SCREAMING_SNAKE_CASE=True						,						__SCREAMING_SNAKE_CASE=None						,						**__SCREAMING_SNAKE_CASE						,						)  ->   List[str]:




           """simple docstring"""







           super().__init__(
               lowerCAmelCase__						,						tokenizer_file=lowerCAmelCase__						,						do_lower_case=lowerCAmelCase__						,						unk_token=lowerCAmelCase__						,						sep_token=lowerCAmelCase__						,						pad_token=lowerCAmelCase__						,						cls_token=lowerCAmelCase__						,						mask_token=lowerCAmelCase__						,						tokenize_chinese_chars=lowerCAmelCase__						,						strip_accents=lowerCAmelCase__						,						**lowerCAmelCase__						,						)

           UpperCamelCase__    :   str					=				json.loads(self.backend_tokenizer.normalizer.__getstate__()  )
           if (
               normalizer_state.get('''lowercase'''						,						lowerCAmelCase__  ) != do_lower_case
               or normalizer_state.get('''strip_accents'''						,						lowerCAmelCase__  ) != strip_accents
               or normalizer_state.get('''handle_chinese_chars'''						,						lowerCAmelCase__  ) != tokenize_chinese_chars
           ):
                 UpperCamelCase__    :   List[Any]					=				getattr(lowerCAmelCase__						,						normalizer_state.pop('''type'''  )  )
                 UpperCamelCase__    :   List[Any]					=				do_lower_case
                 UpperCamelCase__    :   Union[str, Any]					=				strip_accents
                 UpperCamelCase__    :   List[str]					=				tokenize_chinese_chars
                 UpperCamelCase__    :   List[str]					=				normalizer_class(**lowerCAmelCase__  )

           UpperCamelCase__    :   Tuple					=				do_lower_case






     def    __SCREAMING_SNAKE_CASE			(							self						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE=None  )  ->   Optional[Any]:




           """simple docstring"""







           UpperCamelCase__    :   Optional[int]					=				[self.cls_token_id] + token_ids_a + [self.sep_token_id]

           if token_ids_a:
                 output += token_ids_a + [self.sep_token_id]

           return output






     def    __SCREAMING_SNAKE_CASE			(							self						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE = None  )  ->   List[int]:




           """simple docstring"""







           UpperCamelCase__    :   Optional[Any]					=				[self.sep_token_id]
           UpperCamelCase__    :   Optional[int]					=				[self.cls_token_id]
           if token_ids_a is None:
                 return len(cls + token_ids_a + sep  ) * [0]
           return len(cls + token_ids_a + sep  ) * [0] + len(token_ids_a + sep  ) * [1]






     def    __SCREAMING_SNAKE_CASE			(							self						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE = None  )  ->   Tuple[str]:




           """simple docstring"""







           UpperCamelCase__    :   List[Any]					=				self._tokenizer.model.save(lowerCAmelCase__						,						name=lowerCAmelCase__  )
           return tuple(lowerCAmelCase__  )




class 				_lowerCamelCase :





     """simple docstring"""







     def __init__(							self  )  ->   Tuple:




           """simple docstring"""







           UpperCamelCase__    :   Union[str, Any]					=				''''''
           UpperCamelCase__    :   int					=				''''''
           UpperCamelCase__    :   Optional[int]					=				[]






     def    __SCREAMING_SNAKE_CASE			(							self						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )  ->   int:




           """simple docstring"""







           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]:
                       UpperCamelCase__    :   Union[str, Any]					=				self.__min_dist_top_down_dp(m - 1						,						n - 1  )
                 else:
                       UpperCamelCase__    :   int					=				self.__min_dist_top_down_dp(__SCREAMING_SNAKE_CASE						,						n - 1  )
                       UpperCamelCase__    :   Tuple					=				self.__min_dist_top_down_dp(m - 1						,						__SCREAMING_SNAKE_CASE  )
                       UpperCamelCase__    :   Optional[Any]					=				self.__min_dist_top_down_dp(m - 1						,						n - 1  )
                       UpperCamelCase__    :   Optional[int]					=				1 + min(__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )

                 return self.dp[m][n]






     def    __SCREAMING_SNAKE_CASE			(							self						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )  ->   int:




           """simple docstring"""







           UpperCamelCase__    :   Union[str, Any]					=				worda
           UpperCamelCase__    :   Any					=				worda
           UpperCamelCase__    :   List[str]					=				[[-1 for _ in range(len(__SCREAMING_SNAKE_CASE  )  )] for _ in range(len(__SCREAMING_SNAKE_CASE  )  )]

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






     def    __SCREAMING_SNAKE_CASE			(							self						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )  ->   int:




           """simple docstring"""







           UpperCamelCase__    :   int					=				worda
           UpperCamelCase__    :   List[str]					=				worda
           UpperCamelCase__    :   int					=				len(__SCREAMING_SNAKE_CASE  )
           UpperCamelCase__    :   Optional[Any]					=				len(__SCREAMING_SNAKE_CASE  )
           UpperCamelCase__    :   int					=				[[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
                             UpperCamelCase__    :   List[Any]					=				j
                       elif j == 0:  # second string is empty
                             UpperCamelCase__    :   Union[str, Any]					=				i
                       elif worda[i - 1] == worda[j - 1]:  # last characters are equal
                             UpperCamelCase__    :   List[Any]					=				self.dp[i - 1][j - 1]
                       else:
                             UpperCamelCase__    :   Union[str, Any]					=				self.dp[i][j - 1]
                             UpperCamelCase__    :   str					=				self.dp[i - 1][j]
                             UpperCamelCase__    :   Union[str, Any]					=				self.dp[i - 1][j - 1]
                             UpperCamelCase__    :   List[Any]					=				1 + min(__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )
           return self.dp[m][n]


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

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

    lowerCamelCase      =input("Enter the first string: ").strip()
    lowerCamelCase      =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 ***************")


