"""simple docstring"""







from __future__ import annotations




def 						_lowercase				(  _SCREAMING_SNAKE_CASE				:				int  ,       _SCREAMING_SNAKE_CASE				:				int  ,       _SCREAMING_SNAKE_CASE				:				int						)    ->     tuple[float, float]:







     '''simple docstring'''


     assert (
         c % greatest_common_divisor(_SCREAMING_SNAKE_CASE  ,       _SCREAMING_SNAKE_CASE						) == 0
     )  # greatest_common_divisor(a,b) function implemented below
     ((__A)						,		(__A)						,		(__A))					:					Optional[Any]								=		extended_gcd(_SCREAMING_SNAKE_CASE  ,       _SCREAMING_SNAKE_CASE						)  # extended_gcd(a,b) function implemented below
     __A					:					str								=		c / d
     return (r * x, r * y)




def 						_lowercase				(  _SCREAMING_SNAKE_CASE				:				int  ,       _SCREAMING_SNAKE_CASE				:				int  ,       _SCREAMING_SNAKE_CASE				:				int  ,       _SCREAMING_SNAKE_CASE				:				int = 2						)    ->     None:







     '''simple docstring'''


     ((__A)						,		(__A))					:					str								=		diophantine(_SCREAMING_SNAKE_CASE  ,       _SCREAMING_SNAKE_CASE  ,       _SCREAMING_SNAKE_CASE						)  # Initial value
     __A					:					Tuple								=		greatest_common_divisor(_SCREAMING_SNAKE_CASE  ,       _SCREAMING_SNAKE_CASE						)
     __A					:					int								=		a // d
     __A					:					str								=		b // d

     for i in range(_SCREAMING_SNAKE_CASE						):
          __A					:					Optional[int]								=		xa + i * q
          __A					:					str								=		ya - i * p
          print(_SCREAMING_SNAKE_CASE  ,       _SCREAMING_SNAKE_CASE						)




def 						_lowercase				(  _SCREAMING_SNAKE_CASE				:				int  ,       _SCREAMING_SNAKE_CASE				:				int						)    ->     int:







     '''simple docstring'''


     if a < b:
          __A						,		__A					:					Union[str, Any]								=		b, a

     while a % b != 0:
          __A						,		__A					:					Any								=		b, a % b

     return b




def 						_lowercase				(  _SCREAMING_SNAKE_CASE				:				int  ,       _SCREAMING_SNAKE_CASE				:				int						)    ->     tuple[int, int, int]:







     '''simple docstring'''


     assert a >= 0 and b >= 0

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

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

     return (d, x, y)


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

       testmod(name='''diophantine''', verbose=True)
       testmod(name='''diophantine_all_soln''', verbose=True)
       testmod(name='''extended_gcd''', verbose=True)
       testmod(name='''greatest_common_divisor''', verbose=True)




"""simple docstring"""







from typing import Dict, Optional, Tuple

import torch




def 						_lowercase				(  _SCREAMING_SNAKE_CASE				:				torch.Tensor						)    ->     torch.Tensor:







     '''simple docstring'''


     __A					:					List[str]								=		boundaries[1] - boundaries[0]
     __A					:					int								=		boundaries + step / 2
     __A					:					Union[str, Any]								=		torch.cat([bin_centers, (bin_centers[-1] + step).unsqueeze(-1						)]  ,       dim=0						)
     return bin_centers




def 						_lowercase				(  _SCREAMING_SNAKE_CASE				:				torch.Tensor  ,       _SCREAMING_SNAKE_CASE				:				torch.Tensor  ,       )    ->     Tuple[torch.Tensor, torch.Tensor]:







     '''simple docstring'''


     __A					:					str								=		_calculate_bin_centers(_SCREAMING_SNAKE_CASE						)
     return (
         torch.sum(aligned_distance_error_probs * bin_centers  ,       dim=-1						),
         bin_centers[-1],
     )




def 						_lowercase				(  _SCREAMING_SNAKE_CASE				:				torch.Tensor  ,       _SCREAMING_SNAKE_CASE				:				int = 31  ,       _SCREAMING_SNAKE_CASE				:				int = 64  ,       **_SCREAMING_SNAKE_CASE				:				Optional[Any]  ,       )    ->     Dict[str, torch.Tensor]:







     '''simple docstring'''


     __A					:					int								=		torch.linspace(0  ,       _SCREAMING_SNAKE_CASE  ,       steps=(no_bins - 1)  ,       device=logits.device						)

     __A					:					Any								=		torch.nn.functional.softmax(_SCREAMING_SNAKE_CASE  ,       dim=-1						)
     __A						,		__A					:					Tuple								=		_calculate_expected_aligned_error(
         alignment_confidence_breaks=_SCREAMING_SNAKE_CASE  ,       aligned_distance_error_probs=_SCREAMING_SNAKE_CASE  ,       )

     return {
         "aligned_confidence_probs": aligned_confidence_probs,
         "predicted_aligned_error": predicted_aligned_error,
         "max_predicted_aligned_error": max_predicted_aligned_error,
     }




def 						_lowercase				(  _SCREAMING_SNAKE_CASE				:				torch.Tensor  ,       _SCREAMING_SNAKE_CASE				:				Optional[torch.Tensor] = None  ,       _SCREAMING_SNAKE_CASE				:				int = 31  ,       _SCREAMING_SNAKE_CASE				:				int = 64  ,       _SCREAMING_SNAKE_CASE				:				float = 1E-8  ,       **_SCREAMING_SNAKE_CASE				:				Union[str, Any]  ,       )    ->     torch.Tensor:







     '''simple docstring'''


     if residue_weights is None:
          __A					:					Optional[int]								=		logits.new_ones(logits.shape[-2]						)

     __A					:					List[str]								=		torch.linspace(0  ,       _SCREAMING_SNAKE_CASE  ,       steps=(no_bins - 1)  ,       device=logits.device						)

     __A					:					Tuple								=		_calculate_bin_centers(_SCREAMING_SNAKE_CASE						)
     torch.sum(_SCREAMING_SNAKE_CASE						)
     __A					:					int								=		logits.shape[-2]
     __A					:					str								=		max(_SCREAMING_SNAKE_CASE  ,       19						)

     __A					:					Tuple								=		1.24 * (clipped_n - 15) ** (1.0 / 3) - 1.8

     __A					:					Tuple								=		torch.nn.functional.softmax(_SCREAMING_SNAKE_CASE  ,       dim=-1						)

     __A					:					List[str]								=		1.0 / (1 + (bin_centers**2) / (da**2))
     __A					:					int								=		torch.sum(probs * tm_per_bin  ,       dim=-1						)

     __A					:					Any								=		residue_weights / (eps + residue_weights.sum())
     __A					:					List[Any]								=		torch.sum(predicted_tm_term * normed_residue_mask  ,       dim=-1						)

     __A					:					int								=		per_alignment * residue_weights

     __A					:					Optional[int]								=		(weighted == torch.max(_SCREAMING_SNAKE_CASE						)).nonzero()[0]
     return per_alignment[tuple(_SCREAMING_SNAKE_CASE						)]



