






"""simple docstring"""





from typing import Dict, Optional, Tuple

import torch







def 	lowerCAmelCase_(			SCREAMING_SNAKE_CASE       )       ->						torch.Tensor:
    """simple docstring"""

    UpperCamelCase__								=     boundaries[1] - boundaries[0]
    UpperCamelCase__								=     boundaries + step / 2
    UpperCamelCase__								=     torch.cat([bin_centers, (bin_centers[-1] + step).unsqueeze(-1       )]			,						dim=0       )
    return bin_centers







def 	lowerCAmelCase_(			SCREAMING_SNAKE_CASE			,						SCREAMING_SNAKE_CASE			,						)       ->						Tuple[torch.Tensor, torch.Tensor]:
    """simple docstring"""

    UpperCamelCase__								=     _calculate_bin_centers(SCREAMING_SNAKE_CASE       )
    return (
        torch.sum(aligned_distance_error_probs * bin_centers			,						dim=-1       ),
        bin_centers[-1],
    )







def 	lowerCAmelCase_(			SCREAMING_SNAKE_CASE			,						SCREAMING_SNAKE_CASE = 31			,						SCREAMING_SNAKE_CASE = 64			,						**SCREAMING_SNAKE_CASE			,						)       ->						Dict[str, torch.Tensor]:
    """simple docstring"""

    UpperCamelCase__								=     torch.linspace(0			,						SCREAMING_SNAKE_CASE			,						steps=(no_bins - 1)			,						device=logits.device       )

    UpperCamelCase__								=     torch.nn.functional.softmax(SCREAMING_SNAKE_CASE			,						dim=-1       )
    UpperCamelCase__							,    UpperCamelCase__								=     _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 	lowerCAmelCase_(			SCREAMING_SNAKE_CASE			,						SCREAMING_SNAKE_CASE = None			,						SCREAMING_SNAKE_CASE = 31			,						SCREAMING_SNAKE_CASE = 64			,						SCREAMING_SNAKE_CASE = 1E-8			,						**SCREAMING_SNAKE_CASE			,						)       ->						torch.Tensor:
    """simple docstring"""

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

    UpperCamelCase__								=     torch.linspace(0			,						SCREAMING_SNAKE_CASE			,						steps=(no_bins - 1)			,						device=logits.device       )

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

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

    UpperCamelCase__								=     torch.nn.functional.softmax(SCREAMING_SNAKE_CASE			,						dim=-1       )

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

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

    UpperCamelCase__								=     per_alignment * residue_weights

    UpperCamelCase__								=     (weighted == torch.max(SCREAMING_SNAKE_CASE       )).nonzero()[0]
    return per_alignment[tuple(SCREAMING_SNAKE_CASE       )]












"""simple docstring"""





from math import gcd







def 	lowerCAmelCase_(			SCREAMING_SNAKE_CASE = 1_20_00       )       ->						int:
    """simple docstring"""

    UpperCamelCase__								=     0
    for d in range(max_d + 1       ):
        for n in range(d // 3 + 1			,						(d + 1) // 2       ):
            if gcd(SCREAMING_SNAKE_CASE			,						SCREAMING_SNAKE_CASE       ) == 1:
                fractions_number += 1
    return fractions_number


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




