
"""simple docstring"""






lowerCamelCase__ :       List[Any]						     =			256
# Modulus to hash a string
lowerCamelCase__ :       Union[str, Any]						     =			1000003





def 		__A						(   a_ :							str		,		a_ :							str     )->							bool:




		'''simple docstring'''






		SCREAMING_SNAKE_CASE       :     List[Any]				= len(a_     )
		SCREAMING_SNAKE_CASE       :     List[Any]				= len(a_     )
		if p_len > t_len:
				return False

		SCREAMING_SNAKE_CASE       :     Optional[int]				= 0
		SCREAMING_SNAKE_CASE       :     str				= 0
		SCREAMING_SNAKE_CASE       :     Union[str, Any]				= 1

		# Calculating the hash of pattern and substring of text
		for i in range(a_     ):
				SCREAMING_SNAKE_CASE       :     Optional[int]				= (ord(pattern[i]     ) + p_hash * alphabet_size) % modulus
				SCREAMING_SNAKE_CASE       :     Dict				= (ord(text[i]     ) + text_hash * alphabet_size) % modulus
				if i == p_len - 1:
						continue
				SCREAMING_SNAKE_CASE       :     int				= (modulus_power * alphabet_size) % modulus

		for i in range(0		,		t_len - p_len + 1     ):
				if text_hash == p_hash and text[i : i + p_len] == pattern:
						return True
				if i == t_len - p_len:
						continue
				# Calculate the https://en.wikipedia.org/wiki/Rolling_hash
				SCREAMING_SNAKE_CASE       :     Tuple				= (
				    (text_hash - ord(text[i]     ) * modulus_power) * alphabet_size
				    + ord(text[i + p_len]     )
				) % modulus
		return False





def 		__A						(   )->							None:




		'''simple docstring'''






		SCREAMING_SNAKE_CASE       :     Any				= '''abc1abc12'''
		SCREAMING_SNAKE_CASE       :     str				= '''alskfjaldsabc1abc1abc12k23adsfabcabc'''
		SCREAMING_SNAKE_CASE       :     List[Any]				= '''alskfjaldsk23adsfabcabc'''
		assert rabin_karp(a_		,		a_     ) and not rabin_karp(a_		,		a_     )

		# Test 2)
		SCREAMING_SNAKE_CASE       :     List[str]				= '''ABABX'''
		SCREAMING_SNAKE_CASE       :     Optional[int]				= '''ABABZABABYABABX'''
		assert rabin_karp(a_		,		a_     )

		# Test 3)
		SCREAMING_SNAKE_CASE       :     List[Any]				= '''AAAB'''
		SCREAMING_SNAKE_CASE       :     int				= '''ABAAAAAB'''
		assert rabin_karp(a_		,		a_     )

		# Test 4)
		SCREAMING_SNAKE_CASE       :     Tuple				= '''abcdabcy'''
		SCREAMING_SNAKE_CASE       :     Optional[Any]				= '''abcxabcdabxabcdabcdabcy'''
		assert rabin_karp(a_		,		a_     )

		# Test 5)
		SCREAMING_SNAKE_CASE       :     List[Any]				= '''Lü'''
		SCREAMING_SNAKE_CASE       :     List[str]				= '''Lüsai'''
		assert rabin_karp(a_		,		a_     )
		SCREAMING_SNAKE_CASE       :     Optional[int]				= '''Lue'''
		assert not rabin_karp(a_		,		a_     )
		print('''Success.'''     )


if __name__ == "__main__":
					test_rabin_karp()







"""simple docstring"""






from typing import TYPE_CHECKING

from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowerCamelCase__ :       Tuple						     =			{
    "configuration_mctct": ["MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MCTCTConfig"],
    "feature_extraction_mctct": ["MCTCTFeatureExtractor"],
    "processing_mctct": ["MCTCTProcessor"],
}


try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCamelCase__ :       Union[str, Any]						     =			[
					    "MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "MCTCTForCTC",
					    "MCTCTModel",
					    "MCTCTPreTrainedModel",
					]


if TYPE_CHECKING:
					from .configuration_mctct import MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP, MCTCTConfig
					from .feature_extraction_mctct import MCTCTFeatureExtractor
					from .processing_mctct import MCTCTProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_mctct import MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST, MCTCTForCTC, MCTCTModel, MCTCTPreTrainedModel

else:
					import sys

					lowerCamelCase__ :       Tuple						     =			_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





