





'''simple docstring'''



import importlib
import os
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, Optional, Union

import torch

from ..utils import BaseOutput


_SCREAMING_SNAKE_CASE   =      """scheduler_config.json"""






class 							__lowercase    ( lowerCAmelCase__  ):







	'''simple docstring'''

	a      :			str     =    1
	a      :			int     =    2
	a      :			str     =    3
	a      :			List[Any]     =    4
	a      :			Optional[int]     =    5
	a      :			str     =    6
	a      :			int     =    7
	a      :			List[str]     =    8
	a      :			Any     =    9
	a      :			Tuple     =    10
	a      :			str     =    11
	a      :			List[str]     =    12
	a      :			List[str]     =    13
	a      :			Optional[Any]     =    14






@dataclass
class 							__lowercase    ( lowerCAmelCase__  ):







	'''simple docstring'''

	a      :			torch.FloatTensor






class 							__lowercase    :







	'''simple docstring'''

	a      :			int     =    SCHEDULER_CONFIG_NAME
	a      :			str     =    []
	a      :			Tuple     =    True


	@classmethod
	def   _UpperCAmelCase       (cls       ,_lowerCamelCase = None       ,_lowerCamelCase = None       ,_lowerCamelCase=False       ,**_lowerCamelCase       ,)							->							List[Any]:







				'''simple docstring'''





				__lowercase  ,						__lowercase  ,						__lowercase			  =							cls.load_config(
				    pretrained_model_name_or_path=__lowerCAmelCase       ,subfolder=__lowerCAmelCase       ,return_unused_kwargs=__lowerCAmelCase       ,return_commit_hash=__lowerCAmelCase       ,**__lowerCAmelCase       ,)
				return cls.from_config(__lowerCAmelCase       ,return_unused_kwargs=__lowerCAmelCase       ,**__lowerCAmelCase	)


	def   _UpperCAmelCase       (self       ,_lowerCamelCase       ,_lowerCamelCase = False       ,**_lowerCamelCase	)							->							Any:







				'''simple docstring'''





				self.save_config(save_directory=__lowerCAmelCase       ,push_to_hub=__lowerCAmelCase       ,**__lowerCAmelCase	)


	@property
	def   _UpperCAmelCase       (self	)							->							List[Any]:







				'''simple docstring'''





				return self._get_compatibles()


	@classmethod
	def   _UpperCAmelCase       (cls	)							->							Tuple:







				'''simple docstring'''





				__lowercase			  =							list(set([cls.__name__] + cls._compatibles	)	)
				__lowercase			  =							importlib.import_module(__name__.split('''.'''	)[0]	)
				__lowercase			  =							[
				    getattr(__lowerCAmelCase       ,__lowerCAmelCase	) for c in compatible_classes_str if hasattr(__lowerCAmelCase       ,__lowerCAmelCase	)
				]
				return compatible_classes










'''simple docstring'''



def 				_lowerCAmelCase  (			lowerCamelCase_     :					str						,    lowerCamelCase_     :					str			):
			__lowercase			  =							len(lowerCamelCase_			) + 1
			__lowercase			  =							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.
			__lowercase			  =							[[0 for i in range(lowerCamelCase_			)] for j in range(lowerCamelCase_			)]

			# since string of zero length match pattern of zero length
			__lowercase			  =							1

			# since pattern of zero length will never match with string of non-zero length
			for i in range(1						,    lowerCamelCase_			):
						__lowercase			  =							0

			# since string of zero length will match with pattern where there
			# is at least one * alternatively
			for j in range(1						,    lowerCamelCase_			):
						__lowercase			  =							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] == ".":
												__lowercase			  =							dp[i - 1][j - 1]

									elif pattern[j - 1] == "*":
												if dp[i][j - 2] == 1:
															__lowercase			  =							1
												elif pattern[j - 2] in (input_string[i - 1], "."):
															__lowercase			  =							dp[i - 1][j]
												else:
															__lowercase			  =							0
									else:
												__lowercase			  =							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 :")

	_SCREAMING_SNAKE_CASE   =      '''aab'''
	_SCREAMING_SNAKE_CASE   =      '''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}''')





