from typing import Dict, Optional, Tuple

import torch


def SCREAMING_SNAKE_CASE			(       lowercase_:		torch.Tensor			):
       _UpperCamelCase       :    int					  =					boundaries[1] - boundaries[0]
       _UpperCamelCase       :    List[Any]					  =					boundaries + step / 2
       _UpperCamelCase       :    str					  =					torch.cat([bin_centers, (bin_centers[-1] + step).unsqueeze(-1			)]						,  dim=0			)
       return bin_centers


def SCREAMING_SNAKE_CASE			(       lowercase_:		torch.Tensor						,  lowercase_:		torch.Tensor						,  ):
       _UpperCamelCase       :    Optional[Any]					  =					_calculate_bin_centers(lowercase_			)
       return (
           torch.sum(aligned_distance_error_probs * bin_centers						,  dim=-1			),
           bin_centers[-1],
       )


def SCREAMING_SNAKE_CASE			(       lowercase_:		torch.Tensor						,  lowercase_:		int = 31						,  lowercase_:		int = 64						,  **lowercase_:		Union[str, Any]						,  ):
       _UpperCamelCase       :    Optional[Any]					  =					torch.linspace(0						,  lowercase_						,  steps=(no_bins - 1)						,  device=logits.device			)

       _UpperCamelCase       :    Union[str, Any]					  =					torch.nn.functional.softmax(lowercase_						,  dim=-1			)
       _UpperCamelCase  , _UpperCamelCase       :    str					  =					_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 SCREAMING_SNAKE_CASE			(       lowercase_:		torch.Tensor						,  lowercase_:		Optional[torch.Tensor] = None						,  lowercase_:		int = 31						,  lowercase_:		int = 64						,  lowercase_:		float = 1e-8						,  **lowercase_:		Tuple						,  ):
       if residue_weights is None:
              _UpperCamelCase       :    Dict					  =					logits.new_ones(logits.shape[-2]			)

       _UpperCamelCase       :    Optional[int]					  =					torch.linspace(0						,  lowercase_						,  steps=(no_bins - 1)						,  device=logits.device			)

       _UpperCamelCase       :    str					  =					_calculate_bin_centers(lowercase_			)
       torch.sum(lowercase_			)
       _UpperCamelCase       :    List[Any]					  =					logits.shape[-2]
       _UpperCamelCase       :    Optional[int]					  =					max(lowercase_						,  19			)

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

       _UpperCamelCase       :    Optional[int]					  =					torch.nn.functional.softmax(lowercase_						,  dim=-1			)

       _UpperCamelCase       :    Any					  =					1.0 / (1 + (bin_centers**2) / (da**2))
       _UpperCamelCase       :    Union[str, Any]					  =					torch.sum(probs * tm_per_bin						,  dim=-1			)

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

       _UpperCamelCase       :    Dict					  =					per_alignment * residue_weights

       _UpperCamelCase       :    int					  =					(weighted == torch.max(lowercase_			)).nonzero()[0]
       return per_alignment[tuple(lowercase_			)]




def SCREAMING_SNAKE_CASE			(       lowercase_:		int = 4000000			):
       _UpperCamelCase       :    str					  =					1
       _UpperCamelCase       :    str					  =					2
       _UpperCamelCase       :    Tuple					  =					0
       while j <= n:
              if j % 2 == 0:
                     total += j
              _UpperCamelCase  , _UpperCamelCase       :    int					  =					j, i + j

       return total


if __name__ == "__main__":
 print(f'''{solution() = }''')



