





'''simple docstring'''







lowerCAmelCase_   :       Optional[int]       =     2_56
# Modulus to hash a string
lowerCAmelCase_   :       List[Any]       =     1_00_00_03






def 					_lowerCamelCase							(					lowercase		: str       ,				lowercase		: str		)      ->      bool:
				_a				      =					len(_A		)
				_a				      =					len(_A		)
				if p_len > t_len:
								return False

				_a				      =					0
				_a				      =					0
				_a				      =					1

				# Calculating the hash of pattern and substring of text
				for i in range(_A		):
								_a				      =					(ord(pattern[i]		) + p_hash * alphabet_size) % modulus
								_a				      =					(ord(text[i]		) + text_hash * alphabet_size) % modulus
								if i == p_len - 1:
												continue
								_a				      =					(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
								_a				      =					(
								    (text_hash - ord(text[i]		) * modulus_power) * alphabet_size
								    + ord(text[i + p_len]		)
								) % modulus
				return False






def 					_lowerCamelCase							(					)      ->      None:
				_a				      =					"abc1abc12"
				_a				      =					"alskfjaldsabc1abc1abc12k23adsfabcabc"
				_a				      =					"alskfjaldsk23adsfabcabc"
				assert rabin_karp(_A       ,				_A		) and not rabin_karp(_A       ,				_A		)

				# Test 2)
				_a				      =					"ABABX"
				_a				      =					"ABABZABABYABABX"
				assert rabin_karp(_A       ,				_A		)

				# Test 3)
				_a				      =					"AAAB"
				_a				      =					"ABAAAAAB"
				assert rabin_karp(_A       ,				_A		)

				# Test 4)
				_a				      =					"abcdabcy"
				_a				      =					"abcxabcdabxabcdabcdabcy"
				assert rabin_karp(_A       ,				_A		)

				# Test 5)
				_a				      =					"Lü"
				_a				      =					"Lüsai"
				assert rabin_karp(_A       ,				_A		)
				_a				      =					"Lue"
				assert not rabin_karp(_A       ,				_A		)
				print("Success."		)


if __name__ == "__main__":
					test_rabin_karp()




from ...configuration_utils import PretrainedConfig
from ...utils import logging


__UpperCamelCase     		=							logging.get_logger(__name__)

__UpperCamelCase     		=							{
    'microsoft/trocr-base-handwritten': (
        'https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json'
    ),
    # See all TrOCR models at https://huggingface.co/models?filter=trocr
}







class 							lowerCamelCase__						(				UpperCAmelCase   ):






			"""simple docstring"""






			_UpperCamelCase		:       Dict 			=		'trocr'
			_UpperCamelCase		:       Union[str, Any] 			=		['past_key_values']
			_UpperCamelCase		:       Union[str, Any] 			=		{
			    'num_attention_heads': 'decoder_attention_heads',
			    'hidden_size': 'd_model',
			    'num_hidden_layers': 'decoder_layers',
			}




			def __init__(				self   ,    snake_case=50265   ,    snake_case=1024   ,    snake_case=12   ,    snake_case=16   ,    snake_case=4096   ,    snake_case="gelu"   ,    snake_case=512   ,    snake_case=0.1   ,    snake_case=0.0   ,    snake_case=0.0   ,    snake_case=2   ,    snake_case=0.02   ,    snake_case=0.0   ,    snake_case=True   ,    snake_case=False   ,    snake_case=True   ,    snake_case=True   ,    snake_case=1   ,    snake_case=0   ,    snake_case=2   ,    **snake_case   ,    ):

						'''simple docstring'''


						UpperCamelCase__       =							vocab_size
						UpperCamelCase__       =							d_model
						UpperCamelCase__       =							decoder_layers
						UpperCamelCase__       =							decoder_attention_heads
						UpperCamelCase__       =							decoder_ffn_dim
						UpperCamelCase__       =							activation_function
						UpperCamelCase__       =							max_position_embeddings
						UpperCamelCase__       =							dropout
						UpperCamelCase__       =							attention_dropout
						UpperCamelCase__       =							activation_dropout
						UpperCamelCase__       =							init_std
						UpperCamelCase__       =							decoder_layerdrop
						UpperCamelCase__       =							use_cache
						UpperCamelCase__       =							scale_embedding
						UpperCamelCase__       =							use_learned_position_embeddings
						UpperCamelCase__       =							layernorm_embedding

						super().__init__(
						    pad_token_id=snake_case   ,    bos_token_id=snake_case   ,    eos_token_id=snake_case   ,    decoder_start_token_id=snake_case   ,    **snake_case   ,    )


