





"""simple docstring"""





from __future__ import annotations




def 		lowerCAmelCase_	(  lowercase_   :							Tuple ,      lowercase_   :							Tuple ,      lowercase_   :							Any		):

 '''simple docstring'''






 assert n > 1 and a > 0 and greatest_common_divisor(__UpperCAmelCase ,      __UpperCAmelCase		) == 1
 ((__SCREAMING_SNAKE_CASE)							,      (__SCREAMING_SNAKE_CASE)							,      (__SCREAMING_SNAKE_CASE)) :			Tuple												=       extended_gcd(__UpperCAmelCase ,      __UpperCAmelCase		)  # Implemented below
 __SCREAMING_SNAKE_CASE :			List[str]												=       (b * s) % n
 return x




def 		lowerCAmelCase_	(  lowercase_   :							List[str] ,      lowercase_   :							str		):

 '''simple docstring'''






 ((__SCREAMING_SNAKE_CASE)							,      (__SCREAMING_SNAKE_CASE)) :			int												=       extended_euclid(__UpperCAmelCase ,      __UpperCAmelCase		)  # Implemented below
 if b < 0:
  __SCREAMING_SNAKE_CASE :			str												=       (b % n + n) % n
 return b




def 		lowerCAmelCase_	(  lowercase_   :							Union[str, Any] ,      lowercase_   :							Optional[int] ,      lowercase_   :							List[str]		):

 '''simple docstring'''






 __SCREAMING_SNAKE_CASE :			Dict												=       invert_modulo(__UpperCAmelCase ,      __UpperCAmelCase		)
 __SCREAMING_SNAKE_CASE :			Optional[Any]												=       (b * s) % n
 return x




def 		lowerCAmelCase_	(  lowercase_   :							Union[str, Any] ,      lowercase_   :							Tuple		):

 '''simple docstring'''






 assert a >= 0 and b >= 0

 if b == 0:
  __SCREAMING_SNAKE_CASE							,      __SCREAMING_SNAKE_CASE							,      __SCREAMING_SNAKE_CASE :			str												=       a, 1, 0
 else:
  ((__SCREAMING_SNAKE_CASE)							,      (__SCREAMING_SNAKE_CASE)							,      (__SCREAMING_SNAKE_CASE)) :			int												=       extended_gcd(__UpperCAmelCase ,      a % b		)
  __SCREAMING_SNAKE_CASE :			Optional[Any]												=       q
  __SCREAMING_SNAKE_CASE :			Dict												=       p - q * (a // b)

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

 return (d, x, y)




def 		lowerCAmelCase_	(  lowercase_   :							Dict ,      lowercase_   :							Optional[int]		):

 '''simple docstring'''






 if b == 0:
  return (1, 0)
 ((__SCREAMING_SNAKE_CASE)							,      (__SCREAMING_SNAKE_CASE)) :			int												=       extended_euclid(__UpperCAmelCase ,      a % b		)
 __SCREAMING_SNAKE_CASE :			Union[str, Any]												=       a // b
 return (y, x - k * y)




def 		lowerCAmelCase_	(  lowercase_   :							Any ,      lowercase_   :							str		):

 '''simple docstring'''






 if a < b:
  __SCREAMING_SNAKE_CASE							,      __SCREAMING_SNAKE_CASE :			Tuple												=       b, a

 while a % b != 0:
  __SCREAMING_SNAKE_CASE							,      __SCREAMING_SNAKE_CASE :			int												=       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)






from .chunk_utils import chunk_layer
from .data_transforms import make_atomaa_masks
from .feats import atomaa_to_atomaa, frames_and_literature_positions_to_atomaa_pos, torsion_angles_to_frames
from .loss import compute_predicted_aligned_error, compute_tm
from .protein import Protein as OFProtein
from .protein import to_pdb
from .rigid_utils import Rigid, Rotation
from .tensor_utils import dict_multimap, flatten_final_dims, permute_final_dims





