



UpperCAmelCase__       =	256
# Modulus to hash a string
UpperCAmelCase__       =	100_0003





def 							A     (					_UpperCAmelCase    :       str							,       _UpperCAmelCase    :       str   )    ->			bool:







			'''simple docstring'''
			_UpperCAmelCase			=       len(_UpperCAmelCase   )
			_UpperCAmelCase			=       len(_UpperCAmelCase   )
			if p_len > t_len:
						return False

			_UpperCAmelCase			=       0
			_UpperCAmelCase			=       0
			_UpperCAmelCase			=       1

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





def 							A     (					)    ->			None:







			'''simple docstring'''
			_UpperCAmelCase			=       'abc1abc12'
			_UpperCAmelCase			=       'alskfjaldsabc1abc1abc12k23adsfabcabc'
			_UpperCAmelCase			=       'alskfjaldsk23adsfabcabc'
			assert rabin_karp(_UpperCAmelCase							,       _UpperCAmelCase   ) and not rabin_karp(_UpperCAmelCase							,       _UpperCAmelCase   )

			# Test 2)
			_UpperCAmelCase			=       'ABABX'
			_UpperCAmelCase			=       'ABABZABABYABABX'
			assert rabin_karp(_UpperCAmelCase							,       _UpperCAmelCase   )

			# Test 3)
			_UpperCAmelCase			=       'AAAB'
			_UpperCAmelCase			=       'ABAAAAAB'
			assert rabin_karp(_UpperCAmelCase							,       _UpperCAmelCase   )

			# Test 4)
			_UpperCAmelCase			=       'abcdabcy'
			_UpperCAmelCase			=       'abcxabcdabxabcdabcdabcy'
			assert rabin_karp(_UpperCAmelCase							,       _UpperCAmelCase   )

			# Test 5)
			_UpperCAmelCase			=       'Lü'
			_UpperCAmelCase			=       'Lüsai'
			assert rabin_karp(_UpperCAmelCase							,       _UpperCAmelCase   )
			_UpperCAmelCase			=       'Lue'
			assert not rabin_karp(_UpperCAmelCase							,       _UpperCAmelCase   )
			print('Success.'   )


if __name__ == "__main__":
							test_rabin_karp()





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


UpperCAmelCase__       =	logging.get_logger(__name__)

UpperCAmelCase__       =	{
    "edbeeching/decision-transformer-gym-hopper-medium": (
        "https://huggingface.co/edbeeching/decision-transformer-gym-hopper-medium/resolve/main/config.json"
    ),
    # See all DecisionTransformer models at https://huggingface.co/models?filter=decision_transformer
}







class       __lowerCAmelCase   (      A						):
			UpperCamelCase        =					'''decision_transformer'''
			UpperCamelCase        =					['''past_key_values''']
			UpperCamelCase        =					{
			    '''max_position_embeddings''': '''n_positions''',
			    '''num_attention_heads''': '''n_head''',
			    '''num_hidden_layers''': '''n_layer''',
			}



			def __init__(						self       :  Any			,		A       :  Optional[int]=17			,		A       :  List[str]=4			,		A       :  int=1_28			,		A       :  Union[str, Any]=40_96			,		A       :  Any=True			,		A       :  Any=1			,		A       :  List[Any]=10_24			,		A       :  List[Any]=3			,		A       :  Tuple=1			,		A       :  Any=None			,		A       :  Optional[int]="relu"			,		A       :  Union[str, Any]=0.1			,		A       :  Optional[int]=0.1			,		A       :  Optional[int]=0.1			,		A       :  Optional[int]=1E-5			,		A       :  List[Any]=0.0_2			,		A       :  Tuple=True			,		A       :  Union[str, Any]=True			,		A       :  str=5_02_56			,		A       :  Union[str, Any]=5_02_56			,		A       :  List[Any]=False			,		A       :  Optional[int]=False			,		**A       :  int			,		)       ->   Union[str, Any]:



						"""simple docstring"""






						_UpperCAmelCase			=       state_dim
						_UpperCAmelCase			=       act_dim
						_UpperCAmelCase			=       hidden_size
						_UpperCAmelCase			=       max_ep_len
						_UpperCAmelCase			=       action_tanh
						_UpperCAmelCase			=       vocab_size
						_UpperCAmelCase			=       n_positions
						_UpperCAmelCase			=       n_layer
						_UpperCAmelCase			=       n_head
						_UpperCAmelCase			=       n_inner
						_UpperCAmelCase			=       activation_function
						_UpperCAmelCase			=       resid_pdrop
						_UpperCAmelCase			=       embd_pdrop
						_UpperCAmelCase			=       attn_pdrop
						_UpperCAmelCase			=       layer_norm_epsilon
						_UpperCAmelCase			=       initializer_range
						_UpperCAmelCase			=       scale_attn_weights
						_UpperCAmelCase			=       use_cache
						_UpperCAmelCase			=       scale_attn_by_inverse_layer_idx
						_UpperCAmelCase			=       reorder_and_upcast_attn

						_UpperCAmelCase			=       bos_token_id
						_UpperCAmelCase			=       eos_token_id

						super().__init__(bos_token_id=A			,		eos_token_id=A			,		**A)
