
'''simple docstring'''

from __future__ import annotations


def 	_UpperCAmelCase				(  _lowerCamelCase						:       Dict  ,      _lowerCamelCase						:       int  ,      _lowerCamelCase						:       Dict		)    ->						Optional[int]:
  assert n > 1 and a > 0 and greatest_common_divisor(_lowerCamelCase  ,      _lowerCamelCase		) == 1
  (_lowerCAmelCase)       :  Optional[Any]   				=					extended_gcd(_lowerCamelCase  ,      _lowerCamelCase		)  # Implemented below
  _lowerCAmelCase       :  List[str]   				=					(b * s) % n
  return x


def 	_UpperCAmelCase				(  _lowerCamelCase						:       Tuple  ,      _lowerCamelCase						:       List[str]		)    ->						str:
  (_lowerCAmelCase)       :  int   				=					extended_euclid(_lowerCamelCase  ,      _lowerCamelCase		)  # Implemented below
  if b < 0:
    _lowerCAmelCase       :  List[str]   				=					(b % n + n) % n
  return b


def 	_UpperCAmelCase				(  _lowerCamelCase						:       Dict  ,      _lowerCamelCase						:       int  ,      _lowerCamelCase						:       Optional[Any]		)    ->						Union[str, Any]:
  _lowerCAmelCase       :  Union[str, Any]   				=					invert_modulo(_lowerCamelCase  ,      _lowerCamelCase		)
  _lowerCAmelCase       :  Any   				=					(b * s) % n
  return x


def 	_UpperCAmelCase				(  _lowerCamelCase						:       int  ,      _lowerCamelCase						:       Tuple		)    ->						Dict:
  assert a >= 0 and b >= 0

  if b == 0:
    _lowerCAmelCase       :  List[Any]   				=					a, 1, 0
  else:
    (_lowerCAmelCase)       :  Tuple   				=					extended_gcd(_lowerCamelCase  ,      a % b		)
    _lowerCAmelCase       :  Union[str, Any]   				=					q
    _lowerCAmelCase       :  Union[str, Any]   				=					p - q * (a // b)

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

  return (d, x, y)


def 	_UpperCAmelCase				(  _lowerCamelCase						:       Any  ,      _lowerCamelCase						:       str		)    ->						Union[str, Any]:
  if b == 0:
    return (1, 0)
  (_lowerCAmelCase)       :  List[str]   				=					extended_euclid(_lowerCamelCase  ,      a % b		)
  _lowerCAmelCase       :  Optional[Any]   				=					a // b
  return (y, x - k * y)


def 	_UpperCAmelCase				(  _lowerCamelCase						:       Optional[Any]  ,      _lowerCamelCase						:       str		)    ->						str:
  if a < b:
    _lowerCAmelCase       :  str   				=					b, a

  while a % b != 0:
    _lowerCAmelCase       :  Union[str, Any]   				=					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_flax_available,
    is_tf_available,
    is_torch_available,
)


UpperCamelCase_     			=       {
    """configuration_gptsan_japanese""": ["""GPTSAN_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTSanJapaneseConfig"""],
    """tokenization_gptsan_japanese""": ["""GPTSanJapaneseTokenizer"""],
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     UpperCamelCase_     			=       [
         """GPTSAN_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST""",
         """GPTSanJapaneseForConditionalGeneration""",
         """GPTSanJapaneseModel""",
         """GPTSanJapanesePreTrainedModel""",
     ]
     UpperCamelCase_     			=       [
         """GPTSanJapaneseTokenizer""",
     ]


if TYPE_CHECKING:
     from .configuration_gptsan_japanese import GPTSAN_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTSanJapaneseConfig
     from .tokenization_gptsan_japanese import GPTSanJapaneseTokenizer

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_gptsan_japanese import (
              GPTSAN_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST,
              GPTSanJapaneseForConditionalGeneration,
              GPTSanJapaneseModel,
              GPTSanJapanesePreTrainedModel,
          )
          from .tokenization_gptsan_japanese import GPTSanJapaneseTokenizer


else:
     import sys

     UpperCamelCase_     			=       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


