


class   _lowerCamelCase :




       """simple docstring"""



       def __init__(      self		)->int:




         '''simple docstring'''





         A_      :				List[str]		     =					''''''
         A_      :				str		     =					''''''
         A_      :				Union[str, Any]		     =					[]



       def        _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]:
             A_      :				List[str]		     =					self.__min_dist_top_down_dp(m - 1				,       n - 1		)
           else:
             A_      :				Tuple		     =					self.__min_dist_top_down_dp(_SCREAMING_SNAKE_CASE				,       n - 1		)
             A_      :				Optional[int]		     =					self.__min_dist_top_down_dp(m - 1				,       _SCREAMING_SNAKE_CASE		)
             A_      :				List[str]		     =					self.__min_dist_top_down_dp(m - 1				,       n - 1		)
             A_      :				Any		     =					1 + min(_SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE		)

           return self.dp[m][n]



       def        _snake_case       (      self				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE		)->int:




         '''simple docstring'''





         A_      :				Tuple		     =					worda
         A_      :				Dict		     =					worda
         A_      :				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        _snake_case       (      self				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE		)->int:




         '''simple docstring'''





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


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

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

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








from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    center_crop,
    convert_to_rgb,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    OPENAI_CLIP_MEAN,
    OPENAI_CLIP_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


UpperCamelCase								=	logging.get_logger(__name__)


if is_vision_available():
     import PIL






class   _lowerCamelCase (					UpperCamelCase			):




       """simple docstring"""
       snake_case      =    ["pixel_values"]



       def __init__(      self				,       _SCREAMING_SNAKE_CASE = True				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = PILImageResampling.BICUBIC				,       _SCREAMING_SNAKE_CASE = True				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = True				,       _SCREAMING_SNAKE_CASE = 1 / 255				,       _SCREAMING_SNAKE_CASE = True				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = True				,       **_SCREAMING_SNAKE_CASE				,       )->None:




         '''simple docstring'''





         super().__init__(**_SCREAMING_SNAKE_CASE		)
         A_      :				Tuple		     =					size if size is not None else {'''shortest_edge''': 224}
         A_      :				Any		     =					get_size_dict(_SCREAMING_SNAKE_CASE				,       default_to_square=_SCREAMING_SNAKE_CASE		)
         A_      :				Tuple		     =					crop_size if crop_size is not None else {'''height''': 224, '''width''': 224}
         A_      :				Dict		     =					get_size_dict(_SCREAMING_SNAKE_CASE				,       default_to_square=_SCREAMING_SNAKE_CASE				,       param_name='''crop_size'''		)

         A_      :				str		     =					do_resize
         A_      :				Tuple		     =					size
         A_      :				Optional[Any]		     =					resample
         A_      :				Tuple		     =					do_center_crop
         A_      :				List[Any]		     =					crop_size
         A_      :				Optional[int]		     =					do_rescale
         A_      :				Tuple		     =					rescale_factor
         A_      :				Any		     =					do_normalize
         A_      :				int		     =					image_mean if image_mean is not None else OPENAI_CLIP_MEAN
         A_      :				Any		     =					image_std if image_std is not None else OPENAI_CLIP_STD
         A_      :				Any		     =					do_convert_rgb



       def        _snake_case       (      self				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE = PILImageResampling.BICUBIC				,       _SCREAMING_SNAKE_CASE = None				,       **_SCREAMING_SNAKE_CASE				,       )->np.ndarray:




         '''simple docstring'''





         A_      :				Dict		     =					get_size_dict(_SCREAMING_SNAKE_CASE				,       default_to_square=_SCREAMING_SNAKE_CASE		)
         if "shortest_edge" not in size:
           raise ValueError(F'''The `size` parameter must contain the key `shortest_edge`. Got {size.keys()}'''		)
         A_      :				Any		     =					get_resize_output_image_size(_SCREAMING_SNAKE_CASE				,       size=size['''shortest_edge''']				,       default_to_square=_SCREAMING_SNAKE_CASE		)
         return resize(_SCREAMING_SNAKE_CASE				,       size=_SCREAMING_SNAKE_CASE				,       resample=_SCREAMING_SNAKE_CASE				,       data_format=_SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE		)



       def        _snake_case       (      self				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE = None				,       **_SCREAMING_SNAKE_CASE				,       )->np.ndarray:




         '''simple docstring'''





         A_      :				str		     =					get_size_dict(_SCREAMING_SNAKE_CASE		)
         if "height" not in size or "width" not in size:
           raise ValueError(F'''The `size` parameter must contain the keys (height, width). Got {size.keys()}'''		)
         return center_crop(_SCREAMING_SNAKE_CASE				,       size=(size['''height'''], size['''width'''])				,       data_format=_SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE		)



       def        _snake_case       (      self				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE = None				,       **_SCREAMING_SNAKE_CASE				,       )->int:




         '''simple docstring'''





         return rescale(_SCREAMING_SNAKE_CASE				,       scale=_SCREAMING_SNAKE_CASE				,       data_format=_SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE		)



       def        _snake_case       (      self				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE = None				,       **_SCREAMING_SNAKE_CASE				,       )->np.ndarray:




         '''simple docstring'''





         return normalize(_SCREAMING_SNAKE_CASE				,       mean=_SCREAMING_SNAKE_CASE				,       std=_SCREAMING_SNAKE_CASE				,       data_format=_SCREAMING_SNAKE_CASE				,       **_SCREAMING_SNAKE_CASE		)







       def        _snake_case       (      self				,       _SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = None				,       _SCREAMING_SNAKE_CASE = ChannelDimension.FIRST				,       **_SCREAMING_SNAKE_CASE				,       )->PIL.Image.Image:




         '''simple docstring'''





         A_      :				Optional[int]		     =					do_resize if do_resize is not None else self.do_resize
         A_      :				int		     =					size if size is not None else self.size
         A_      :				Optional[int]		     =					get_size_dict(_SCREAMING_SNAKE_CASE				,       param_name='''size'''				,       default_to_square=_SCREAMING_SNAKE_CASE		)
         A_      :				List[Any]		     =					resample if resample is not None else self.resample
         A_      :				Any		     =					do_center_crop if do_center_crop is not None else self.do_center_crop
         A_      :				List[str]		     =					crop_size if crop_size is not None else self.crop_size
         A_      :				int		     =					get_size_dict(_SCREAMING_SNAKE_CASE				,       param_name='''crop_size'''				,       default_to_square=_SCREAMING_SNAKE_CASE		)
         A_      :				Optional[int]		     =					do_rescale if do_rescale is not None else self.do_rescale
         A_      :				int		     =					rescale_factor if rescale_factor is not None else self.rescale_factor
         A_      :				int		     =					do_normalize if do_normalize is not None else self.do_normalize
         A_      :				Tuple		     =					image_mean if image_mean is not None else self.image_mean
         A_      :				Tuple		     =					image_std if image_std is not None else self.image_std
         A_      :				List[str]		     =					do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

         A_      :				Optional[int]		     =					make_list_of_images(_SCREAMING_SNAKE_CASE		)

         if not valid_images(_SCREAMING_SNAKE_CASE		):
           raise ValueError(
               '''Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '''
               '''torch.Tensor, tf.Tensor or jax.ndarray.'''		)

         if do_resize and size is None:
           raise ValueError('''Size must be specified if do_resize is True.'''		)

         if do_center_crop and crop_size is None:
           raise ValueError('''Crop size must be specified if do_center_crop is True.'''		)

         if do_rescale and rescale_factor is None:
           raise ValueError('''Rescale factor must be specified if do_rescale is True.'''		)

         if do_normalize and (image_mean is None or image_std is None):
           raise ValueError('''Image mean and std must be specified if do_normalize is True.'''		)

         # PIL RGBA images are converted to RGB
         if do_convert_rgb:
           A_      :				List[str]		     =					[convert_to_rgb(_SCREAMING_SNAKE_CASE		) for image in images]

         # All transformations expect numpy arrays.
         A_      :				int		     =					[to_numpy_array(_SCREAMING_SNAKE_CASE		) for image in images]

         if do_resize:
           A_      :				Tuple		     =					[self.resize(image=_SCREAMING_SNAKE_CASE				,       size=_SCREAMING_SNAKE_CASE				,       resample=_SCREAMING_SNAKE_CASE		) for image in images]

         if do_center_crop:
           A_      :				Union[str, Any]		     =					[self.center_crop(image=_SCREAMING_SNAKE_CASE				,       size=_SCREAMING_SNAKE_CASE		) for image in images]

         if do_rescale:
           A_      :				Tuple		     =					[self.rescale(image=_SCREAMING_SNAKE_CASE				,       scale=_SCREAMING_SNAKE_CASE		) for image in images]

         if do_normalize:
           A_      :				List[Any]		     =					[self.normalize(image=_SCREAMING_SNAKE_CASE				,       mean=_SCREAMING_SNAKE_CASE				,       std=_SCREAMING_SNAKE_CASE		) for image in images]

         A_      :				str		     =					[to_channel_dimension_format(_SCREAMING_SNAKE_CASE				,       _SCREAMING_SNAKE_CASE		) for image in images]

         A_      :				Optional[Any]		     =					{'''pixel_values''': images}
         return BatchFeature(data=_SCREAMING_SNAKE_CASE				,       tensor_type=_SCREAMING_SNAKE_CASE		)




