__magic_name__								=256
# Modulus to hash a string
__magic_name__								=1000003







def  __UpperCamelCase    (						A ,							A							):
     UpperCamelCase__										=      len(A							)
     UpperCamelCase__										=      len(A							)
     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(A							):
          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  __UpperCamelCase    (						):
     UpperCamelCase__										=      '''abc1abc12'''
     UpperCamelCase__										=      '''alskfjaldsabc1abc1abc12k23adsfabcabc'''
     UpperCamelCase__										=      '''alskfjaldsk23adsfabcabc'''
     assert rabin_karp(A ,							A							) and not rabin_karp(A ,							A							)

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

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

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

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


if __name__ == "__main__":
     test_rabin_karp()




import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
     import torch

     from transformers.activations import gelu_new, gelu_python, get_activation



@require_torch
class     _A   (    unittest.TestCase							):






  def 		_a					(self	)		->      str:





       '''simple docstring'''





       UpperCamelCase__										=      torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]	)
       UpperCamelCase__										=      get_activation('''gelu'''	)
       self.assertTrue(torch.allclose(gelu_python(SCREAMING_SNAKE_CASE_	)   ,				torch_builtin(SCREAMING_SNAKE_CASE_	)	)	)
       self.assertFalse(torch.allclose(gelu_python(SCREAMING_SNAKE_CASE_	)   ,				gelu_new(SCREAMING_SNAKE_CASE_	)	)	)






  def 		_a					(self	)		->      str:





       '''simple docstring'''





       UpperCamelCase__										=      torch.tensor([-100, -1, -0.1, 0, 0.1, 1.0, 100]	)
       UpperCamelCase__										=      get_activation('''gelu'''	)
       UpperCamelCase__										=      get_activation('''gelu_10'''	)

       UpperCamelCase__										=      torch_builtin(SCREAMING_SNAKE_CASE_	)
       UpperCamelCase__										=      geluaa(SCREAMING_SNAKE_CASE_	)

       UpperCamelCase__										=      torch.where(y_gelu_aa < 10.0   ,				1   ,				0	)

       self.assertTrue(torch.max(SCREAMING_SNAKE_CASE_	).item() == 10.0	)
       self.assertTrue(torch.allclose(y_gelu * clipped_mask   ,				y_gelu_aa * clipped_mask	)	)






  def 		_a					(self	)		->      Optional[Any]:





       '''simple docstring'''





       get_activation('''gelu'''	)
       get_activation('''gelu_10'''	)
       get_activation('''gelu_fast'''	)
       get_activation('''gelu_new'''	)
       get_activation('''gelu_python'''	)
       get_activation('''gelu_pytorch_tanh'''	)
       get_activation('''linear'''	)
       get_activation('''mish'''	)
       get_activation('''quick_gelu'''	)
       get_activation('''relu'''	)
       get_activation('''sigmoid'''	)
       get_activation('''silu'''	)
       get_activation('''swish'''	)
       get_activation('''tanh'''	)
       with self.assertRaises(SCREAMING_SNAKE_CASE_	):
            get_activation('''bogus'''	)
       with self.assertRaises(SCREAMING_SNAKE_CASE_	):
            get_activation(SCREAMING_SNAKE_CASE_	)






  def 		_a					(self	)		->      Optional[Any]:





       '''simple docstring'''





       UpperCamelCase__										=      get_activation('''gelu'''	)
       UpperCamelCase__										=      1
       UpperCamelCase__										=      get_activation('''gelu'''	)
       self.assertEqual(acta.a   ,				1	)
       with self.assertRaises(SCREAMING_SNAKE_CASE_	):
            UpperCamelCase__										=      acta.a



