




from typing import Dict, Optional, Tuple

import torch
def 							__lowerCAmelCase			(UpperCAmelCase_		):
    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 							__lowerCAmelCase			(UpperCAmelCase_ ,     UpperCAmelCase_ ,     ):
    a__  			=							_calculate_bin_centers(UpperCAmelCase_		)
    return (
        torch.sum(aligned_distance_error_probs * bin_centers ,     dim=-1		),
        bin_centers[-1],
    )
def 							__lowerCAmelCase			(UpperCAmelCase_ ,     UpperCAmelCase_ = 31 ,     UpperCAmelCase_ = 64 ,     **UpperCAmelCase_ ,     ):
    a__  			=							torch.linspace(0 ,     UpperCAmelCase_ ,     steps=(no_bins - 1) ,     device=logits.device		)

    a__  			=							torch.nn.functional.softmax(UpperCAmelCase_ ,     dim=-1		)
    a__			,		a__  			=							_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 							__lowerCAmelCase			(UpperCAmelCase_ ,     UpperCAmelCase_ = None ,     UpperCAmelCase_ = 31 ,     UpperCAmelCase_ = 64 ,     UpperCAmelCase_ = 1E-8 ,     **UpperCAmelCase_ ,     ):
    if residue_weights is None:
        a__  			=							logits.new_ones(logits.shape[-2]		)

    a__  			=							torch.linspace(0 ,     UpperCAmelCase_ ,     steps=(no_bins - 1) ,     device=logits.device		)

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

    a__  			=							1.2_4 * (clipped_n - 15) ** (1.0 / 3) - 1.8

    a__  			=							torch.nn.functional.softmax(UpperCAmelCase_ ,     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(UpperCAmelCase_		)).nonzero()[0]
    return per_alignment[tuple(UpperCAmelCase_		)]












from __future__ import annotations

import random







class 		__UpperCAmelCase:





     """simple docstring"""



     __UpperCAmelCase						:			Optional[int]							=     6

     def __init__(   self			:							int     )      ->      Optional[Any]:






         """simple docstring"""
         a__  			=							list(range(1    ,					Dice.NUM_SIDES + 1     )     )






     def 					__SCREAMING_SNAKE_CASE		(   self			:							Union[str, Any]     )      ->      List[str]:






         """simple docstring"""
         return random.choice(self.sides     )






def 							__lowerCAmelCase			(UpperCAmelCase_ ,     UpperCAmelCase_ = 2		):
    a__  			=							[Dice() for i in range(UpperCAmelCase_		)]
    a__  			=							[0] * (len(UpperCAmelCase_		) * Dice.NUM_SIDES + 1)
    for _ in range(UpperCAmelCase_		):
        count_of_sum[sum(dice.roll() for dice in dices		)] += 1
    a__  			=							[round((count * 100) / num_throws ,     2		) for count in count_of_sum]
    return probability[num_dice:]  # remove probability of sums that never appear


if __name__ == "__main__":
 import doctest

 doctest.testmod()






