


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


__UpperCamelCase       :       List[Any]						       =				logging.get_logger(__name__)

__UpperCamelCase       :       Dict						       =				{
    "transfo-xl-wt103": "https://huggingface.co/transfo-xl-wt103/resolve/main/config.json",
}

class       __magic_name__	(     __lowerCAmelCase):
     A:		Union[str, Any]			=      "transfo-xl"
     A:		List[Any]			=      ["mems"]
     A:		Tuple			=      {
         "n_token": "vocab_size",
         "hidden_size": "d_model",
         "num_attention_heads": "n_head",
         "num_hidden_layers": "n_layer",
     }


     def __init__(      self							:     Tuple							,	lowerCamelCase__							:     str=267735							,	lowerCamelCase__							:     Dict=[20000, 40000, 200000]							,	lowerCamelCase__							:     Dict=1024							,	lowerCamelCase__							:     Any=1024							,	lowerCamelCase__							:     Any=16							,	lowerCamelCase__							:     Optional[Any]=64							,	lowerCamelCase__							:     Any=4096							,	lowerCamelCase__							:     str=4							,	lowerCamelCase__							:     Dict=False							,	lowerCamelCase__							:     Union[str, Any]=18							,	lowerCamelCase__							:     str=1600							,	lowerCamelCase__							:     Any=1000							,	lowerCamelCase__							:     Any=True							,	lowerCamelCase__							:     int=True							,	lowerCamelCase__							:     Tuple=0							,	lowerCamelCase__							:     str=-1							,	lowerCamelCase__							:     List[Any]=True							,	lowerCamelCase__							:     List[Any]=0.1							,	lowerCamelCase__							:     int=0.0							,	lowerCamelCase__							:     Union[str, Any]=True							,	lowerCamelCase__							:     Union[str, Any]="normal"							,	lowerCamelCase__							:     str=0.01							,	lowerCamelCase__							:     Optional[Any]=0.01							,	lowerCamelCase__							:     List[str]=0.02							,	lowerCamelCase__							:     Dict=1E-5							,	lowerCamelCase__							:     Dict=0							,	**lowerCamelCase__							:     List[str]							,	)  ->      Dict:





      '''simple docstring'''






      UpperCamelCase__					:    Dict          =   vocab_size
      UpperCamelCase__					:    Optional[Any]          =   []
      self.cutoffs.extend(lowerCamelCase__			)
      if proj_share_all_but_first:
       UpperCamelCase__					:    List[str]          =   [False] + [True] * len(self.cutoffs			)
      else:
       UpperCamelCase__					:    List[Any]          =   [False] + [False] * len(self.cutoffs			)
      UpperCamelCase__					:    Dict          =   d_model
      UpperCamelCase__					:    Union[str, Any]          =   d_embed
      UpperCamelCase__					:    Tuple          =   d_head
      UpperCamelCase__					:    int          =   d_inner
      UpperCamelCase__					:    Tuple          =   div_val
      UpperCamelCase__					:    List[str]          =   pre_lnorm
      UpperCamelCase__					:    Union[str, Any]          =   n_layer
      UpperCamelCase__					:    Any          =   n_head
      UpperCamelCase__					:    Tuple          =   mem_len
      UpperCamelCase__					:    Dict          =   same_length
      UpperCamelCase__					:    int          =   attn_type
      UpperCamelCase__					:    Dict          =   clamp_len
      UpperCamelCase__					:    int          =   sample_softmax
      UpperCamelCase__					:    List[str]          =   adaptive
      UpperCamelCase__					:    Any          =   dropout
      UpperCamelCase__					:    int          =   dropatt
      UpperCamelCase__					:    Union[str, Any]          =   untie_r
      UpperCamelCase__					:    Dict          =   init
      UpperCamelCase__					:    Union[str, Any]          =   init_range
      UpperCamelCase__					:    Union[str, Any]          =   proj_init_std
      UpperCamelCase__					:    str          =   init_std
      UpperCamelCase__					:    List[Any]          =   layer_norm_epsilon
      super().__init__(eos_token_id=lowerCamelCase__							,	**lowerCamelCase__			)


     @property
     def      UpperCAmelCase__	(      self							:     int			)  ->      List[str]:





      '''simple docstring'''






      logger.info(F"The model {self.model_type} is one of the few models that has no sequence length limit."			)
      return -1


     @max_position_embeddings.setter
     def      UpperCAmelCase__	(      self							:     Optional[Any]							,	lowerCamelCase__							:     Tuple			)  ->      Union[str, Any]:





      '''simple docstring'''






      raise NotImplementedError(
          F"The model {self.model_type} is one of the few models that has no sequence length limit."			)






__UpperCamelCase       :       List[Any]						       =				256
# Modulus to hash a string
__UpperCamelCase       :       Union[str, Any]						       =				100_0003

def 			_a  (				SCREAMING_SNAKE_CASE	:				str    , SCREAMING_SNAKE_CASE	:				str     ):







 """simple docstring"""



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

 UpperCamelCase__					:    Any          =   0
 UpperCamelCase__					:    str          =   0
 UpperCamelCase__					:    List[Any]          =   1

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

def 			_a  (				):







 """simple docstring"""



 UpperCamelCase__					:    Tuple          =   '''abc1abc12'''
 UpperCamelCase__					:    Dict          =   '''alskfjaldsabc1abc1abc12k23adsfabcabc'''
 UpperCamelCase__					:    List[str]          =   '''alskfjaldsk23adsfabcabc'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     ) and not rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )

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

 # Test 3)
 UpperCamelCase__					:    int          =   '''AAAB'''
 UpperCamelCase__					:    str          =   '''ABAAAAAB'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )

 # Test 4)
 UpperCamelCase__					:    Union[str, Any]          =   '''abcdabcy'''
 UpperCamelCase__					:    List[str]          =   '''abcxabcdabxabcdabcdabcy'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )

 # Test 5)
 UpperCamelCase__					:    Tuple          =   '''Lü'''
 UpperCamelCase__					:    Any          =   '''Lüsai'''
 assert rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )
 UpperCamelCase__					:    Dict          =   '''Lue'''
 assert not rabin_karp(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )
 print('''Success.'''     )


if __name__ == "__main__":
       test_rabin_karp()


