

"""simple docstring"""



from typing import Dict, Optional, Tuple

import torch





def 			_snake_case  (     UpperCAmelCase_	:       Optional[Any]      ):
     A__				      =	boundaries[1] - boundaries[0]
     A__				      =	boundaries + step / 2
     A__				      =	torch.cat([bin_centers, (bin_centers[-1] + step).unsqueeze(-1      )]       , dim=0      )
     return bin_centers





def 			_snake_case  (     UpperCAmelCase_	:       Dict       , UpperCAmelCase_	:       List[Any]       , ):
     A__				      =	_calculate_bin_centers(lowercase_      )
     return (
         torch.sum(aligned_distance_error_probs * bin_centers       , dim=-1      ),
         bin_centers[-1],
     )





def 			_snake_case  (     UpperCAmelCase_	:       List[str]       , UpperCAmelCase_	:       str = 31       , UpperCAmelCase_	:       Tuple = 64       , **UpperCAmelCase_	:       Optional[int]       , ):
     A__				      =	torch.linspace(0       , lowercase_       , steps=(no_bins - 1)       , device=logits.device      )

     A__				      =	torch.nn.functional.softmax(lowercase_       , dim=-1      )
     A__      ,					A__				      =	_calculate_expected_aligned_error(
         alignment_confidence_breaks=lowercase_       , aligned_distance_error_probs=lowercase_       , )

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





def 			_snake_case  (     UpperCAmelCase_	:       Optional[int]       , UpperCAmelCase_	:       str = None       , UpperCAmelCase_	:       Any = 31       , UpperCAmelCase_	:       str = 64       , UpperCAmelCase_	:       Optional[int] = 1e-8       , **UpperCAmelCase_	:       Tuple       , ):





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

     A__				      =	torch.linspace(0       , lowercase_       , steps=(no_bins - 1)       , device=logits.device      )

     A__				      =	_calculate_bin_centers(lowercase_      )
     torch.sum(lowercase_      )
     A__				      =	logits.shape[-2]
     A__				      =	max(lowercase_       , 19      )

     A__				      =	1.24 * (clipped_n - 15) ** (1.0 / 3) - 1.8

     A__				      =	torch.nn.functional.softmax(lowercase_       , dim=-1      )

     A__				      =	1.0 / (1 + (bin_centers**2) / (da**2))
     A__				      =	torch.sum(probs * tm_per_bin       , dim=-1      )

     A__				      =	residue_weights / (eps + residue_weights.sum())
     A__				      =	torch.sum(predicted_tm_term * normed_residue_mask       , dim=-1      )

     A__				      =	per_alignment * residue_weights

     A__				      =	(weighted == torch.max(lowercase_      )).nonzero()[0]
     return per_alignment[tuple(lowercase_      )]









def   UpperCamelCase(   lowercase_ = 100     ,   lowercase_ = 100				)      ->							int:





  '''simple docstring'''





  return max(
      sum(int(lowercase_				) for x in str(base**power				)				)
      for base in range(lowercase_				)
      for power in range(lowercase_				)				)


# Tests
if __name__ == "__main__":
    import doctest

    doctest.testmod()