
import os
import unittest

from huggingface_hub.utils import are_progress_bars_disabled

import transformers.models.bart.tokenization_bart
from transformers import logging
from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context
from transformers.utils.logging import disable_progress_bar, enable_progress_bar




class 				_lowerCamelCase (      unittest.TestCase ):





     """simple docstring"""







     def    __SCREAMING_SNAKE_CASE			(							self  )  ->   str:




           """simple docstring"""







           UpperCamelCase__    :   Union[str, Any]					=				logging.get_logger()

           # the current default level is logging.WARNING
           UpperCamelCase__    :   int					=				logging.get_verbosity()

           logging.set_verbosity_error()
           self.assertEqual(logger.getEffectiveLevel()						,						logging.get_verbosity()  )

           logging.set_verbosity_warning()
           self.assertEqual(logger.getEffectiveLevel()						,						logging.get_verbosity()  )

           logging.set_verbosity_info()
           self.assertEqual(logger.getEffectiveLevel()						,						logging.get_verbosity()  )

           logging.set_verbosity_debug()
           self.assertEqual(logger.getEffectiveLevel()						,						logging.get_verbosity()  )

           # restore to the original level
           logging.set_verbosity(__SCREAMING_SNAKE_CASE  )






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




           """simple docstring"""







           UpperCamelCase__    :   Dict					=				logging.get_verbosity()

           UpperCamelCase__    :   Union[str, Any]					=				logging.get_logger('''transformers.models.bart.tokenization_bart'''  )
           UpperCamelCase__    :   Optional[int]					=				'''Testing 1, 2, 3'''

           # should be able to log warnings (if default settings weren't overridden by `pytest --log-level-all`)
           if level_origin <= logging.WARNING:
                 with CaptureLogger(__SCREAMING_SNAKE_CASE  ) as cl:
                       logger.warning(__SCREAMING_SNAKE_CASE  )
                 self.assertEqual(cl.out						,						msg + '''\n'''  )

           # this is setting the level for all of `transformers.*` loggers
           logging.set_verbosity_error()

           # should not be able to log warnings
           with CaptureLogger(__SCREAMING_SNAKE_CASE  ) as cl:
                 logger.warning(__SCREAMING_SNAKE_CASE  )
           self.assertEqual(cl.out						,						''''''  )

           # should be able to log warnings again
           logging.set_verbosity_warning()
           with CaptureLogger(__SCREAMING_SNAKE_CASE  ) as cl:
                 logger.warning(__SCREAMING_SNAKE_CASE  )
           self.assertEqual(cl.out						,						msg + '''\n'''  )

           # restore to the original level
           logging.set_verbosity(__SCREAMING_SNAKE_CASE  )






     @mockenv(TRANSFORMERS_VERBOSITY='''error'''  )
     def    __SCREAMING_SNAKE_CASE			(							self  )  ->   List[str]:




           """simple docstring"""







           transformers.utils.logging._reset_library_root_logger()
           # this action activates the env var
           UpperCamelCase__    :   Tuple					=				logging.get_logger('''transformers.models.bart.tokenization_bart'''  )

           UpperCamelCase__    :   Dict					=				os.getenv('''TRANSFORMERS_VERBOSITY'''						,						__SCREAMING_SNAKE_CASE  )
           UpperCamelCase__    :   Tuple					=				logging.log_levels[env_level_str]

           UpperCamelCase__    :   Any					=				logging.get_verbosity()
           self.assertEqual(
               __SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE						,						F'''TRANSFORMERS_VERBOSITY={env_level_str}/{env_level}, but internal verbosity is {current_level}'''						,						)

           # restore to the original level
           UpperCamelCase__    :   Any					=				''''''
           transformers.utils.logging._reset_library_root_logger()






     @mockenv(TRANSFORMERS_VERBOSITY='''super-error'''  )
     def    __SCREAMING_SNAKE_CASE			(							self  )  ->   str:




           """simple docstring"""







           transformers.utils.logging._reset_library_root_logger()
           UpperCamelCase__    :   List[Any]					=				logging.logging.getLogger()
           with CaptureLogger(__SCREAMING_SNAKE_CASE  ) as cl:
                 # this action activates the env var
                 logging.get_logger('''transformers.models.bart.tokenization_bart'''  )
           self.assertIn('''Unknown option TRANSFORMERS_VERBOSITY=super-error'''						,						cl.out  )

           # no need to restore as nothing was changed






     def    __SCREAMING_SNAKE_CASE			(							self  )  ->   Any:




           """simple docstring"""







           transformers.utils.logging._reset_library_root_logger()

           UpperCamelCase__    :   Optional[Any]					=				logging.get_logger('''transformers.models.bart.tokenization_bart'''  )
           UpperCamelCase__    :   Any					=				'''Testing 1, 2, 3'''

           with mockenv_context(TRANSFORMERS_NO_ADVISORY_WARNINGS='''1'''  ):
                 # nothing should be logged as env var disables this method
                 with CaptureLogger(__SCREAMING_SNAKE_CASE  ) as cl:
                       logger.warning_advice(__SCREAMING_SNAKE_CASE  )
                 self.assertEqual(cl.out						,						''''''  )

           with mockenv_context(TRANSFORMERS_NO_ADVISORY_WARNINGS=''''''  ):
                 # should log normally as TRANSFORMERS_NO_ADVISORY_WARNINGS is unset
                 with CaptureLogger(__SCREAMING_SNAKE_CASE  ) as cl:
                       logger.warning_advice(__SCREAMING_SNAKE_CASE  )
                 self.assertEqual(cl.out						,						msg + '''\n'''  )


def 							SCREAMING_SNAKE_CASE_      (			):
      disable_progress_bar()
      assert are_progress_bars_disabled()

      enable_progress_bar()
      assert not are_progress_bars_disabled()




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 ***************")


