





'''simple docstring'''







class 					__a      :

							def __init__(							self							:     Dict   )					->       str:







													"""simple docstring"""
													UpperCAmelCase_			:      str     						=  ''''''
													UpperCAmelCase_			:      List[Any]     						=  ''''''
													UpperCAmelCase_			:      Optional[int]     						=  []

							def     UpperCAmelCase__	(							self							:     List[Any]       ,     __magic_name__							:     int       ,     __magic_name__							:     int   )					->       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_			:      List[str]     						=  self.__min_dist_top_down_dp(__UpperCamelCase       ,     n - 1   )
																									UpperCAmelCase_			:      Dict     						=  self.__min_dist_top_down_dp(m - 1       ,     __UpperCamelCase   )
																									UpperCAmelCase_			:      Union[str, Any]     						=  self.__min_dist_top_down_dp(m - 1       ,     n - 1   )
																									UpperCAmelCase_			:      int     						=  1 + min(__UpperCamelCase       ,     __UpperCamelCase       ,     __UpperCamelCase   )

																			return self.dp[m][n]

							def     UpperCAmelCase__	(							self							:     List[Any]       ,     __magic_name__							:     str       ,     __magic_name__							:     str   )					->       int:







													"""simple docstring"""
													UpperCAmelCase_			:      Dict     						=  worda
													UpperCAmelCase_			:      Tuple     						=  worda
													UpperCAmelCase_			:      List[Any]     						=  [[-1 for _ in range(len(__UpperCamelCase   )   )] for _ in range(len(__UpperCamelCase   )   )]

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



							def     UpperCAmelCase__	(							self							:     Tuple       ,     __magic_name__							:     str       ,     __magic_name__							:     str   )					->       int:







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


if __name__ == "__main__":
					lowerCamelCase     :       List[Any]						=  EditDistance()

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

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












'''simple docstring'''







import json
import os
import unittest

from transformers.models.blenderbot_small.tokenization_blenderbot_small import (
    VOCAB_FILES_NAMES,
    BlenderbotSmallTokenizer,
)

from ...test_tokenization_common import TokenizerTesterMixin


class 					__a      (lowerCamelCase       ,		unittest.TestCase     ):
							__a					:   List[str]									=       BlenderbotSmallTokenizer
							__a					:   List[Any]									=       False

							def     UpperCAmelCase__	(							self							:     str   )					->       str:







													"""simple docstring"""
													super().setUp()

													UpperCAmelCase_			:      Tuple     						=  ['''__start__''', '''adapt''', '''act''', '''ap@@''', '''te''', '''__end__''', '''__unk__''']
													UpperCAmelCase_			:      Optional[Any]     						=  dict(zip(__magic_name__       ,     range(len(__magic_name__   )   )   )   )

													UpperCAmelCase_			:      int     						=  ['''#version: 0.2''', '''a p''', '''t e</w>''', '''ap t</w>''', '''a d''', '''ad apt</w>''', '''a c''', '''ac t</w>''', '''''']
													UpperCAmelCase_			:      Optional[Any]     						=  {'''unk_token''': '''__unk__''', '''bos_token''': '''__start__''', '''eos_token''': '''__end__'''}

													UpperCAmelCase_			:      Tuple     						=  os.path.join(self.tmpdirname       ,     VOCAB_FILES_NAMES['''vocab_file''']   )
													UpperCAmelCase_			:      Dict     						=  os.path.join(self.tmpdirname       ,     VOCAB_FILES_NAMES['''merges_file''']   )
													with open(self.vocab_file       ,     '''w'''       ,     encoding='''utf-8'''   ) as fp:
																			fp.write(json.dumps(__magic_name__   ) + '''\n'''   )
													with open(self.merges_file       ,     '''w'''       ,     encoding='''utf-8'''   ) as fp:
																			fp.write('''\n'''.join(__magic_name__   )   )

							def     UpperCAmelCase__	(							self							:     List[Any]       ,     **__magic_name__							:     Dict   )					->       Tuple:







													"""simple docstring"""
													kwargs.update(self.special_tokens_map   )
													return BlenderbotSmallTokenizer.from_pretrained(self.tmpdirname       ,     **__magic_name__   )

							def     UpperCAmelCase__	(							self							:     Optional[int]       ,     __magic_name__							:     List[str]   )					->       List[str]:







													"""simple docstring"""
													UpperCAmelCase_			:      str     						=  '''adapt act apte'''
													UpperCAmelCase_			:      Tuple     						=  '''adapt act apte'''
													return input_text, output_text

							def     UpperCAmelCase__	(							self							:     str   )					->       Any:







													"""simple docstring"""
													UpperCAmelCase_			:      str     						=  BlenderbotSmallTokenizer(self.vocab_file       ,     self.merges_file       ,     **self.special_tokens_map   )
													UpperCAmelCase_			:      List[Any]     						=  '''adapt act apte'''
													UpperCAmelCase_			:      Dict     						=  ['''adapt''', '''act''', '''ap@@''', '''te''']
													UpperCAmelCase_			:      Dict     						=  tokenizer.tokenize(__magic_name__   )
													self.assertListEqual(__magic_name__       ,     __magic_name__   )

													UpperCAmelCase_			:      Tuple     						=  [tokenizer.bos_token] + tokens + [tokenizer.eos_token]

													UpperCAmelCase_			:      Dict     						=  [0, 1, 2, 3, 4, 5]
													self.assertListEqual(tokenizer.convert_tokens_to_ids(__magic_name__   )       ,     __magic_name__   )

							def     UpperCAmelCase__	(							self							:     int   )					->       List[str]:







													"""simple docstring"""
													UpperCAmelCase_			:      List[Any]     						=  BlenderbotSmallTokenizer.from_pretrained('''facebook/blenderbot-90M'''   )
													assert tok('''sam'''   ).input_ids == [13_84]
													UpperCAmelCase_			:      Optional[int]     						=  '''I am a small frog.'''
													UpperCAmelCase_			:      List[str]     						=  tok([src_text]       ,     padding=__magic_name__       ,     truncation=__magic_name__   )['''input_ids''']
													UpperCAmelCase_			:      Dict     						=  tok.batch_decode(__magic_name__       ,     skip_special_tokens=__magic_name__       ,     clean_up_tokenization_spaces=__magic_name__   )[0]
													assert src_text != decoded  # I wish it did!
													assert decoded == "i am a small frog ."



							def     UpperCAmelCase__	(							self							:     Any   )					->       Union[str, Any]:







													"""simple docstring"""
													UpperCAmelCase_			:      int     						=  BlenderbotSmallTokenizer.from_pretrained('''facebook/blenderbot-90M'''   )
													UpperCAmelCase_			:      List[Any]     						=  '''I am a small frog .'''
													UpperCAmelCase_			:      Any     						=  '''.'''
													UpperCAmelCase_			:      List[Any]     						=  tok(__magic_name__   )['''input_ids''']
													UpperCAmelCase_			:      Optional[int]     						=  tok(__magic_name__   )['''input_ids''']

													assert encoded[-1] == encoded_dot[0]





