





"""simple docstring"""


import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
   import torch

if is_vision_available():
   from PIL import Image

   from transformers import ConvNextImageProcessor



class   lowercase_					(  unittest.TestCase				):

       def __init__(      self ,       __SCREAMING_SNAKE_CASE ,       __SCREAMING_SNAKE_CASE=7 ,       __SCREAMING_SNAKE_CASE=3 ,       __SCREAMING_SNAKE_CASE=18 ,       __SCREAMING_SNAKE_CASE=30 ,       __SCREAMING_SNAKE_CASE=400 ,       __SCREAMING_SNAKE_CASE=True ,       __SCREAMING_SNAKE_CASE=None ,       __SCREAMING_SNAKE_CASE=0.875 ,       __SCREAMING_SNAKE_CASE=True ,       __SCREAMING_SNAKE_CASE=[0.5, 0.5, 0.5] ,       __SCREAMING_SNAKE_CASE=[0.5, 0.5, 0.5] ,       ):






        '''simple docstring'''

        snake_case__     				=					size if size is not None else {"shortest_edge": 20}
        snake_case__     				=					parent
        snake_case__     				=					batch_size
        snake_case__     				=					num_channels
        snake_case__     				=					image_size
        snake_case__     				=					min_resolution
        snake_case__     				=					max_resolution
        snake_case__     				=					do_resize
        snake_case__     				=					size
        snake_case__     				=					crop_pct
        snake_case__     				=					do_normalize
        snake_case__     				=					image_mean
        snake_case__     				=					image_std

       def 		_SCREAMING_SNAKE_CASE(      self  ):






        '''simple docstring'''

        return {
            "image_mean": self.image_mean,
            "image_std": self.image_std,
            "do_normalize": self.do_normalize,
            "do_resize": self.do_resize,
            "size": self.size,
            "crop_pct": self.crop_pct,
        }



@require_torch
@require_vision
class   lowercase_					(  __lowerCAmelCase					,unittest.TestCase				):
       snake_case__					:				Any									=  ConvNextImageProcessor if is_vision_available() else None

       def 		_SCREAMING_SNAKE_CASE(      self  ):






        '''simple docstring'''

        snake_case__     				=					ConvNextImageProcessingTester(self  )

       @property
       def 		_SCREAMING_SNAKE_CASE(      self  ):






        '''simple docstring'''

        return self.image_processor_tester.prepare_image_processor_dict()

       def 		_SCREAMING_SNAKE_CASE(      self  ):






        '''simple docstring'''

        snake_case__     				=					self.image_processing_class(**self.image_processor_dict  )
        self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE ,       "do_resize"  )  )
        self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE ,       "size"  )  )
        self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE ,       "crop_pct"  )  )
        self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE ,       "do_normalize"  )  )
        self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE ,       "image_mean"  )  )
        self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE ,       "image_std"  )  )

       def 		_SCREAMING_SNAKE_CASE(      self  ):






        '''simple docstring'''

        snake_case__     				=					self.image_processing_class.from_dict(self.image_processor_dict  )
        self.assertEqual(image_processor.size ,       {"shortest_edge": 20}  )

        snake_case__     				=					self.image_processing_class.from_dict(self.image_processor_dict ,       size=42  )
        self.assertEqual(image_processor.size ,       {"shortest_edge": 42}  )

       def 		_SCREAMING_SNAKE_CASE(      self  ):






        '''simple docstring'''

        pass

       def 		_SCREAMING_SNAKE_CASE(      self  ):






        '''simple docstring'''

        snake_case__     				=					self.image_processing_class(**self.image_processor_dict  )
        # create random PIL images
        snake_case__     				=					prepare_image_inputs(self.image_processor_tester ,       equal_resolution=__SCREAMING_SNAKE_CASE  )
        for image in image_inputs:
         self.assertIsInstance(__SCREAMING_SNAKE_CASE ,       Image.Image  )

        # Test not batched input
        snake_case__     				=					image_processing(image_inputs[0] ,       return_tensors="pt"  ).pixel_values
        self.assertEqual(
            encoded_images.shape ,       (
                1,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.size["shortest_edge"],
                self.image_processor_tester.size["shortest_edge"],
            ) ,       )

        # Test batched
        snake_case__     				=					image_processing(__SCREAMING_SNAKE_CASE ,       return_tensors="pt"  ).pixel_values
        self.assertEqual(
            encoded_images.shape ,       (
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.size["shortest_edge"],
                self.image_processor_tester.size["shortest_edge"],
            ) ,       )

       def 		_SCREAMING_SNAKE_CASE(      self  ):






        '''simple docstring'''

        snake_case__     				=					self.image_processing_class(**self.image_processor_dict  )
        # create random numpy tensors
        snake_case__     				=					prepare_image_inputs(self.image_processor_tester ,       equal_resolution=__SCREAMING_SNAKE_CASE ,       numpify=__SCREAMING_SNAKE_CASE  )
        for image in image_inputs:
         self.assertIsInstance(__SCREAMING_SNAKE_CASE ,       np.ndarray  )

        # Test not batched input
        snake_case__     				=					image_processing(image_inputs[0] ,       return_tensors="pt"  ).pixel_values
        self.assertEqual(
            encoded_images.shape ,       (
                1,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.size["shortest_edge"],
                self.image_processor_tester.size["shortest_edge"],
            ) ,       )

        # Test batched
        snake_case__     				=					image_processing(__SCREAMING_SNAKE_CASE ,       return_tensors="pt"  ).pixel_values
        self.assertEqual(
            encoded_images.shape ,       (
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.size["shortest_edge"],
                self.image_processor_tester.size["shortest_edge"],
            ) ,       )

       def 		_SCREAMING_SNAKE_CASE(      self  ):






        '''simple docstring'''

        snake_case__     				=					self.image_processing_class(**self.image_processor_dict  )
        # create random PyTorch tensors
        snake_case__     				=					prepare_image_inputs(self.image_processor_tester ,       equal_resolution=__SCREAMING_SNAKE_CASE ,       torchify=__SCREAMING_SNAKE_CASE  )
        for image in image_inputs:
         self.assertIsInstance(__SCREAMING_SNAKE_CASE ,       torch.Tensor  )

        # Test not batched input
        snake_case__     				=					image_processing(image_inputs[0] ,       return_tensors="pt"  ).pixel_values
        self.assertEqual(
            encoded_images.shape ,       (
                1,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.size["shortest_edge"],
                self.image_processor_tester.size["shortest_edge"],
            ) ,       )

        # Test batched
        snake_case__     				=					image_processing(__SCREAMING_SNAKE_CASE ,       return_tensors="pt"  ).pixel_values
        self.assertEqual(
            encoded_images.shape ,       (
                self.image_processor_tester.batch_size,
                self.image_processor_tester.num_channels,
                self.image_processor_tester.size["shortest_edge"],
                self.image_processor_tester.size["shortest_edge"],
            ) ,       )








"""simple docstring"""


def 				a__      (	_UpperCAmelCase						,  _UpperCAmelCase						)     ->	int:

 '''simple docstring'''






 if len(_UpperCAmelCase						) < len(_UpperCAmelCase						):
  return levenshtein_distance(_UpperCAmelCase						,  _UpperCAmelCase						)

 if len(_UpperCAmelCase						) == 0:
  return len(_UpperCAmelCase						)

 snake_case__     				=					list(range(len(_UpperCAmelCase						) + 1						)						)

 for i, ca in enumerate(_UpperCAmelCase						):
  snake_case__     				=					[i + 1]

  for j, ca in enumerate(_UpperCAmelCase						):
   # Calculate insertions, deletions and substitutions
   snake_case__     				=					previous_row[j + 1] + 1
   snake_case__     				=					current_row[j] + 1
   snake_case__     				=					previous_row[j] + (ca != ca)

   # Get the minimum to append to the current row
   current_row.append(min(_UpperCAmelCase						,  _UpperCAmelCase						,  _UpperCAmelCase						)						)

  # Store the previous row
  snake_case__     				=					current_row

 # Returns the last element (distance)
 return previous_row[-1]


if __name__ == "__main__":
   a__       :  Optional[int]       		=					input("""Enter the first word:\n""").strip()
   a__       :  int       		=					input("""Enter the second word:\n""").strip()

   a__       :  Union[str, Any]       		=					levenshtein_distance(first_word, second_word)
   print(f'''Levenshtein distance between {first_word} and {second_word} is {result}''')

