





def 	lowerCAmelCase_					(						__UpperCAmelCase:    List[str]	,     __UpperCAmelCase:    List[Any]   )   ->			bool:
				UpperCamelCase__							:       Optional[Any]      =   len(__lowerCAmelCase   ) + 1
				UpperCamelCase__							:       int      =   len(__lowerCAmelCase   ) + 1

				# dp is a 2d matrix where dp[i][j] denotes whether prefix string of
				# length i of input_string matches with prefix string of length j of
				# given pattern.
				# "dp" stands for dynamic programming.
				UpperCamelCase__							:       Dict      =   [[0 for i in range(__lowerCAmelCase   )] for j in range(__lowerCAmelCase   )]

				# since string of zero length match pattern of zero length
				UpperCamelCase__							:       Dict      =   1

				# since pattern of zero length will never match with string of non-zero length
				for i in range(1	,     __lowerCAmelCase   ):
								UpperCamelCase__							:       Union[str, Any]      =   0

				# since string of zero length will match with pattern where there
				# is at least one * alternatively
				for j in range(1	,     __lowerCAmelCase   ):
								UpperCamelCase__							:       int      =   dp[0][j - 2] if pattern[j - 1] == """*""" else 0

				# now using bottom-up approach to find for all remaining lengths
				for i in range(1	,     __lowerCAmelCase   ):
								for j in range(1	,     __lowerCAmelCase   ):
												if input_string[i - 1] == pattern[j - 1] or pattern[j - 1] == ".":
																UpperCamelCase__							:       Any      =   dp[i - 1][j - 1]

												elif pattern[j - 1] == "*":
																if dp[i][j - 2] == 1:
																				UpperCamelCase__							:       List[str]      =   1
																elif pattern[j - 2] in (input_string[i - 1], "."):
																				UpperCamelCase__							:       List[Any]      =   dp[i - 1][j]
																else:
																				UpperCamelCase__							:       Optional[int]      =   0
												else:
																UpperCamelCase__							:       Dict      =   0

				return bool(dp[-1][-1]   )


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		# inputing the strings
		# input_string = input("input a string :")
		# pattern = input("input a pattern :")

		UpperCAmelCase_  							=				"aab"
		UpperCAmelCase_  							=				"c*a*b"

		# using function to check whether given string matches the given pattern
		if match_pattern(input_string, pattern):
				print(F'''{input_string} matches the given pattern {pattern}''')
		else:
				print(F'''{input_string} does not match with the given pattern {pattern}''')








import gc
import tempfile
import unittest

import numpy as np
import torch

from diffusers import VersatileDiffusionTextToImagePipeline
from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device


UpperCAmelCase_  							=				False






class 					lowercase__ (			unittest.TestCase       ):

   '''simple docstring'''


   pass






@nightly
@require_torch_gpu
class 					lowercase__ (			unittest.TestCase       ):

   '''simple docstring'''


   def    UpperCamelCase__						(					self							)				->   Optional[Any]:






       """simple docstring"""
       # clean up the VRAM after each test
       super().tearDown()
       gc.collect()
       torch.cuda.empty_cache()




   def    UpperCamelCase__						(					self							)				->   List[Any]:






       """simple docstring"""
       UpperCamelCase__							:       Dict      =   VersatileDiffusionTextToImagePipeline.from_pretrained('''shi-labs/versatile-diffusion'''							)
       # remove text_unet
       pipe.remove_unused_weights()
       pipe.to(__magic_name__							)
       pipe.set_progress_bar_config(disable=__magic_name__							)

       UpperCamelCase__							:       int      =   '''A painting of a squirrel eating a burger '''
       UpperCamelCase__							:       str      =   torch.manual_seed(0							)
       UpperCamelCase__							:       int      =   pipe(
           prompt=__magic_name__,	generator=__magic_name__,	guidance_scale=7.5,	num_inference_steps=2,	output_type='''numpy'''							).images

       with tempfile.TemporaryDirectory() as tmpdirname:
           pipe.save_pretrained(__magic_name__							)
           UpperCamelCase__							:       Union[str, Any]      =   VersatileDiffusionTextToImagePipeline.from_pretrained(__magic_name__							)
       pipe.to(__magic_name__							)
       pipe.set_progress_bar_config(disable=__magic_name__							)

       UpperCamelCase__							:       Optional[Any]      =   generator.manual_seed(0							)
       UpperCamelCase__							:       str      =   pipe(
           prompt=__magic_name__,	generator=__magic_name__,	guidance_scale=7.5,	num_inference_steps=2,	output_type='''numpy'''							).images

       assert np.abs(image - new_image							).sum() < 1E-5, "Models don't have the same forward pass"




   def    UpperCamelCase__						(					self							)				->   Any:






       """simple docstring"""
       UpperCamelCase__							:       str      =   VersatileDiffusionTextToImagePipeline.from_pretrained(
           '''shi-labs/versatile-diffusion''',	torch_dtype=torch.floataa							)
       pipe.to(__magic_name__							)
       pipe.set_progress_bar_config(disable=__magic_name__							)

       UpperCamelCase__							:       Optional[int]      =   '''A painting of a squirrel eating a burger '''
       UpperCamelCase__							:       str      =   torch.manual_seed(0							)
       UpperCamelCase__							:       Optional[int]      =   pipe(
           prompt=__magic_name__,	generator=__magic_name__,	guidance_scale=7.5,	num_inference_steps=50,	output_type='''numpy'''							).images

       UpperCamelCase__							:       int      =   image[0, 253:256, 253:256, -1]

       assert image.shape == (1, 512, 512, 3)
       UpperCamelCase__							:       int      =   np.array([0.3367, 0.3169, 0.2656, 0.3870, 0.4790, 0.3796, 0.4009, 0.4878, 0.4778]							)

       assert np.abs(image_slice.flatten() - expected_slice							).max() < 1E-2

