



'''simple docstring'''





class 	lowerCAmelCase_:
  '''simple docstring'''




  def __init__(   self				)   ->		Dict:
      lowerCAmelCase__			:  Union[str, Any]											= """"""
      lowerCAmelCase__			:  Optional[int]											= """"""
      lowerCAmelCase__			:  List[Any]											= []




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

          return self.dp[m][n]




  def 							UpperCAmelCase_     (   self  ,__UpperCAmelCase  ,__UpperCAmelCase				)   ->		int:
      lowerCAmelCase__			:  List[Any]											= worda
      lowerCAmelCase__			:  List[str]											= worda
      lowerCAmelCase__			:  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  ,__UpperCAmelCase  ,__UpperCAmelCase				)   ->		int:
      lowerCAmelCase__			:  List[str]											= worda
      lowerCAmelCase__			:  int											= worda
      lowerCAmelCase__			:  int											= len(__UpperCAmelCase				)
      lowerCAmelCase__			:  Union[str, Any]											= len(__UpperCAmelCase				)
      lowerCAmelCase__			:  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
                  lowerCAmelCase__			:  Optional[Any]											= j
              elif j == 0:  # second string is empty
                  lowerCAmelCase__			:  Optional[Any]											= i
              elif worda[i - 1] == worda[j - 1]:  # last characters are equal
                  lowerCAmelCase__			:  str											= self.dp[i - 1][j - 1]
              else:
                  lowerCAmelCase__			:  Optional[Any]											= self.dp[i][j - 1]
                  lowerCAmelCase__			:  Any											= self.dp[i - 1][j]
                  lowerCAmelCase__			:  Union[str, Any]											= self.dp[i - 1][j - 1]
                  lowerCAmelCase__			:  List[str]											= 1 + min(__UpperCAmelCase  ,__UpperCAmelCase  ,__UpperCAmelCase				)
      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 ***************''')







'''simple docstring'''





import unittest

import torch

from diffusers import VQModel
from diffusers.utils import floats_tensor, torch_device
from diffusers.utils.testing_utils import enable_full_determinism

from .test_modeling_common import ModelTesterMixin, UNetTesterMixin


enable_full_determinism()






class 	lowerCAmelCase_(    SCREAMING_SNAKE_CASE_						,			SCREAMING_SNAKE_CASE_						,			unittest.TestCase					):
  '''simple docstring'''




  __lowercase							:				Optional[Any]           =				VQModel
  __lowercase							:				Tuple           =				'''sample'''




  @property
  def 							UpperCAmelCase_     (   self  ,__UpperCAmelCase=(32, 32)				)   ->		List[Any]:
      lowerCAmelCase__			:  Dict											= 4
      lowerCAmelCase__			:  List[str]											= 3

      lowerCAmelCase__			:  Dict											= floats_tensor((batch_size, num_channels) + sizes				).to(__UpperCAmelCase				)

      return {"sample": image}




  @property
  def 							UpperCAmelCase_     (   self				)   ->		List[Any]:
      return (3, 32, 32)




  @property
  def 							UpperCAmelCase_     (   self				)   ->		Optional[Any]:
      return (3, 32, 32)




  def 							UpperCAmelCase_     (   self				)   ->		List[Any]:
      lowerCAmelCase__			:  Dict											= {
          """block_out_channels""": [32, 64],
          """in_channels""": 3,
          """out_channels""": 3,
          """down_block_types""": ["""DownEncoderBlock2D""", """DownEncoderBlock2D"""],
          """up_block_types""": ["""UpDecoderBlock2D""", """UpDecoderBlock2D"""],
          """latent_channels""": 3,
      }
      lowerCAmelCase__			:  Any											= self.dummy_input
      return init_dict, inputs_dict




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




  def 							UpperCAmelCase_     (   self				)   ->		Optional[int]:
      pass




  def 							UpperCAmelCase_     (   self				)   ->		Tuple:
      lowerCAmelCase__				,       lowerCAmelCase__			:  Union[str, Any]											= VQModel.from_pretrained("""fusing/vqgan-dummy"""  ,output_loading_info=__UpperCAmelCase				)
      self.assertIsNotNone(__UpperCAmelCase				)
      self.assertEqual(len(loading_info["""missing_keys"""]				)  ,0				)

      model.to(__UpperCAmelCase				)
      lowerCAmelCase__			:  List[Any]											= model(**self.dummy_input				)

      assert image is not None, "Make sure output is not None"






  def 							UpperCAmelCase_     (   self				)   ->		List[str]:
      lowerCAmelCase__			:  Tuple											= VQModel.from_pretrained("""fusing/vqgan-dummy"""				)
      model.to(__UpperCAmelCase				).eval()

      torch.manual_seed(0				)
      if torch.cuda.is_available():
          torch.cuda.manual_seed_all(0				)

      lowerCAmelCase__			:  List[str]											= torch.randn(1  ,model.config.in_channels  ,model.config.sample_size  ,model.config.sample_size				)
      lowerCAmelCase__			:  Optional[Any]											= image.to(__UpperCAmelCase				)
      with torch.no_grad():
          lowerCAmelCase__			:  Optional[Any]											= model(__UpperCAmelCase				).sample

      lowerCAmelCase__			:  Tuple											= output[0, -1, -3:, -3:].flatten().cpu()
      # fmt: off
      lowerCAmelCase__			:  Tuple											= torch.tensor([-0.0_1_5_3, -0.4_0_4_4, -0.1_8_8_0, -0.5_1_6_1, -0.2_4_1_8, -0.4_0_7_2, -0.1_6_1_2, -0.0_6_3_3, -0.0_1_4_3]				)
      # fmt: on
      self.assertTrue(torch.allclose(__UpperCAmelCase  ,__UpperCAmelCase  ,atol=1E-3				)				)


