




'''simple docstring'''
from __future__ import annotations
def 							snake_case_    (  a__						:      Optional[int]       ,a__						:      Union[str, Any]       ,a__						:      Any     ):



    """simple docstring"""




    assert n > 1 and a > 0 and greatest_common_divisor(lowerCamelCase_       ,lowerCamelCase_     ) == 1
    ((__lowercase)							,(__lowercase)							,(__lowercase))     							=		extended_gcd(lowerCamelCase_       ,lowerCamelCase_     )  # Implemented below
    __lowercase     							=		(b * s) % n
    return x
def 							snake_case_    (  a__						:      Optional[int]       ,a__						:      Optional[Any]     ):



    """simple docstring"""




    ((__lowercase)							,(__lowercase))     							=		extended_euclid(lowerCamelCase_       ,lowerCamelCase_     )  # Implemented below
    if b < 0:
        __lowercase     							=		(b % n + n) % n
    return b
def 							snake_case_    (  a__						:      Optional[Any]       ,a__						:      Optional[Any]       ,a__						:      Any     ):



    """simple docstring"""




    __lowercase     							=		invert_modulo(lowerCamelCase_       ,lowerCamelCase_     )
    __lowercase     							=		(b * s) % n
    return x
def 							snake_case_    (  a__						:      Optional[Any]       ,a__						:      Optional[Any]     ):



    """simple docstring"""




    assert a >= 0 and b >= 0

    if b == 0:
        __lowercase							,__lowercase							,__lowercase     							=		a, 1, 0
    else:
        ((__lowercase)							,(__lowercase)							,(__lowercase))     							=		extended_gcd(lowerCamelCase_       ,a % b     )
        __lowercase     							=		q
        __lowercase     							=		p - q * (a // b)

    assert a % d == 0 and b % d == 0
    assert d == a * x + b * y

    return (d, x, y)
def 							snake_case_    (  a__						:      Optional[Any]       ,a__						:      int     ):



    """simple docstring"""




    if b == 0:
        return (1, 0)
    ((__lowercase)							,(__lowercase))     							=		extended_euclid(lowerCamelCase_       ,a % b     )
    __lowercase     							=		a // b
    return (y, x - k * y)
def 							snake_case_    (  a__						:      Optional[Any]       ,a__						:      Dict     ):



    """simple docstring"""




    if a < b:
        __lowercase							,__lowercase     							=		b, a

    while a % b != 0:
        __lowercase							,__lowercase     							=		b, a % b

    return b


if __name__ == "__main__":
  from doctest import testmod

  testmod(name="""modular_division""", verbose=True)
  testmod(name="""modular_division2""", verbose=True)
  testmod(name="""invert_modulo""", verbose=True)
  testmod(name="""extended_gcd""", verbose=True)
  testmod(name="""extended_euclid""", verbose=True)
  testmod(name="""greatest_common_divisor""", verbose=True)












"""simple docstring"""







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available


__a							:						Tuple   							=			{}

try:
	if not is_sentencepiece_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__a							:						str   							=			['CpmTokenizer']

try:
	if not is_tokenizers_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__a							:						List[str]   							=			['CpmTokenizerFast']


if TYPE_CHECKING:
	try:
		if not is_sentencepiece_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_cpm import CpmTokenizer

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_cpm_fast import CpmTokenizerFast

else:
	import sys

	__a							:						Tuple   							=			_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)


