


'''simple docstring'''



from typing import Dict, Optional, Tuple

import torch



def       UpperCAmelCase__ (     UpperCAmelCase_   :    torch.Tensor							)					->		torch.Tensor:
     __lowerCamelCase       :     Optional[Any]        =		boundaries[1] - boundaries[0]
     __lowerCamelCase       :     Dict        =		boundaries + step / 2
     __lowerCamelCase       :     Optional[Any]        =		torch.cat([bin_centers, (bin_centers[-1] + step).unsqueeze(-1							)]				,   dim=0							)
     return bin_centers



def       UpperCAmelCase__ (     UpperCAmelCase_   :    torch.Tensor				,   UpperCAmelCase_   :    torch.Tensor				,   )					->		Tuple[torch.Tensor, torch.Tensor]:
     __lowerCamelCase       :     List[Any]        =		_calculate_bin_centers(UpperCAmelCase_							)
     return (
         torch.sum(aligned_distance_error_probs * bin_centers				,   dim=-1							),
         bin_centers[-1],
     )



def       UpperCAmelCase__ (     UpperCAmelCase_   :    torch.Tensor				,   UpperCAmelCase_   :    int = 31				,   UpperCAmelCase_   :    int = 64				,   **UpperCAmelCase_   :    int				,   )					->		Dict[str, torch.Tensor]:
     __lowerCamelCase       :     Tuple        =		torch.linspace(0				,   UpperCAmelCase_				,   steps=(no_bins - 1)				,   device=logits.device							)

     __lowerCamelCase       :     Any        =		torch.nn.functional.softmax(UpperCAmelCase_				,   dim=-1							)
     __lowerCamelCase    ,	__lowerCamelCase       :     int        =		_calculate_expected_aligned_error(
         alignment_confidence_breaks=UpperCAmelCase_				,   aligned_distance_error_probs=UpperCAmelCase_				,   )

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



def       UpperCAmelCase__ (     UpperCAmelCase_   :    torch.Tensor				,   UpperCAmelCase_   :    Optional[torch.Tensor] = None				,   UpperCAmelCase_   :    int = 31				,   UpperCAmelCase_   :    int = 64				,   UpperCAmelCase_   :    float = 1e-8				,   **UpperCAmelCase_   :    int				,   )					->		torch.Tensor:
     if residue_weights is None:
          __lowerCamelCase       :     Any        =		logits.new_ones(logits.shape[-2]							)

     __lowerCamelCase       :     Dict        =		torch.linspace(0				,   UpperCAmelCase_				,   steps=(no_bins - 1)				,   device=logits.device							)

     __lowerCamelCase       :     Union[str, Any]        =		_calculate_bin_centers(UpperCAmelCase_							)
     torch.sum(UpperCAmelCase_							)
     __lowerCamelCase       :     int        =		logits.shape[-2]
     __lowerCamelCase       :     Any        =		max(UpperCAmelCase_				,   19							)

     __lowerCamelCase       :     int        =		1.24 * (clipped_n - 15) ** (1.0 / 3) - 1.8

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

     __lowerCamelCase       :     Dict        =		1.0 / (1 + (bin_centers**2) / (da**2))
     __lowerCamelCase       :     Tuple        =		torch.sum(probs * tm_per_bin				,   dim=-1							)

     __lowerCamelCase       :     str        =		residue_weights / (eps + residue_weights.sum())
     __lowerCamelCase       :     Optional[int]        =		torch.sum(predicted_tm_term * normed_residue_mask				,   dim=-1							)

     __lowerCamelCase       :     str        =		per_alignment * residue_weights

     __lowerCamelCase       :     List[str]        =		(weighted == torch.max(UpperCAmelCase_							)).nonzero()[0]
     return per_alignment[tuple(UpperCAmelCase_							)]










'''simple docstring'''



def       UpperCAmelCase__ (     UpperCAmelCase_   :    int = 4_00_00_00							)					->		int:
     __lowerCamelCase       :     int        =		1
     __lowerCamelCase       :     Union[str, Any]        =		2
     __lowerCamelCase       :     Optional[int]        =		0
     while j <= n:
          if j % 2 == 0:
               total += j
          __lowerCamelCase    ,	__lowerCamelCase       :     List[Any]        =		j, i + j

     return total


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






