__a    :	Optional[int]         =    2_5_6
# Modulus to hash a string
__a    :	Optional[Any]         =    1_0_0_0_0_0_3





def 							UpperCAmelCase		(       lowercase				,     lowercase				):







				"""simple docstring"""



				__lowercase					     =				len(lowercase				)
				__lowercase					     =				len(lowercase				)
				if p_len > t_len:
								return False

				__lowercase					     =				0
				__lowercase					     =				0
				__lowercase					     =				1

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





def 							UpperCAmelCase		(       ):







				"""simple docstring"""



				__lowercase					     =				'''abc1abc12'''
				__lowercase					     =				'''alskfjaldsabc1abc1abc12k23adsfabcabc'''
				__lowercase					     =				'''alskfjaldsk23adsfabcabc'''
				assert rabin_karp(lowercase				,     lowercase				) and not rabin_karp(lowercase				,     lowercase				)

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

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

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

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


if __name__ == "__main__":
		test_rabin_karp()
import datasets


__a    :	Optional[Any]         =    """\
@InProceedings{conneau2018xnli,
  author = \"Conneau, Alexis
                 and Rinott, Ruty
                 and Lample, Guillaume
                 and Williams, Adina
                 and Bowman, Samuel R.
                 and Schwenk, Holger
                 and Stoyanov, Veselin\",
  title = \"XNLI: Evaluating Cross-lingual Sentence Representations\",
  booktitle = \"Proceedings of the 2018 Conference on Empirical Methods
               in Natural Language Processing\",
  year = \"2018\",
  publisher = \"Association for Computational Linguistics\",
  location = \"Brussels, Belgium\",
}
"""

__a    :	Optional[Any]         =    """\
XNLI is a subset of a few thousand examples from MNLI which has been translated
into a 14 different languages (some low-ish resource). As with MNLI, the goal is
to predict textual entailment (does sentence A imply/contradict/neither sentence
B) and is a classification task (given two sentences, predict one of three
labels).
"""

__a    :	str         =    """
Computes XNLI score which is just simple accuracy.
Args:
    predictions: Predicted labels.
    references: Ground truth labels.
Returns:
    'accuracy': accuracy
Examples:

    >>> predictions = [0, 1]
    >>> references = [0, 1]
    >>> xnli_metric = datasets.load_metric(\"xnli\")
    >>> results = xnli_metric.compute(predictions=predictions, references=references)
    >>> print(results)
    {'accuracy': 1.0}
"""





def 							UpperCAmelCase		(       lowercase				,     lowercase				):







				"""simple docstring"""



				return (preds == labels).mean()




@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION		,_KWARGS_DESCRIPTION					)
class   _UpperCamelCase (		datasets.Metric					):


			"""simple docstring"""






			def 			_SCREAMING_SNAKE_CASE     (  self		)	->   str:

							'''simple docstring'''


							return datasets.MetricInfo(
							    description=_DESCRIPTION ,  citation=_CITATION ,  inputs_description=_KWARGS_DESCRIPTION ,  features=datasets.Features(
							        {
							            '''predictions''': datasets.Value('''int64''' if self.config_name != '''sts-b''' else '''float32'''		),
							            '''references''': datasets.Value('''int64''' if self.config_name != '''sts-b''' else '''float32'''		),
							        }		) ,  codebase_urls=[] ,  reference_urls=[] ,  format='''numpy''' ,  )





			def 			_SCREAMING_SNAKE_CASE     (  self ,  lowerCAmelCase__ ,  lowerCAmelCase__		)	->   Dict:

							'''simple docstring'''


							return {"accuracy": simple_accuracy(lowerCAmelCase__ ,  lowerCAmelCase__		)}