





from typing import Dict, Optional, Tuple

import torch


def        A__						(							SCREAMING_SNAKE_CASE_		) ->  torch.Tensor:
		lowerCamelCase :			Union[str, Any]    		=boundaries[1] - boundaries[0]
		lowerCamelCase :			Dict    		=boundaries + step / 2
		lowerCamelCase :			str    		=torch.cat([bin_centers, (bin_centers[-1] + step).unsqueeze(-1		)]				,							dim=0		)
		return bin_centers


def        A__						(							SCREAMING_SNAKE_CASE_				,							SCREAMING_SNAKE_CASE_				,							) ->  Tuple[torch.Tensor, torch.Tensor]:
		lowerCamelCase :			Any    		=_calculate_bin_centers(SCREAMING_SNAKE_CASE_		)
		return (
		    torch.sum(aligned_distance_error_probs * bin_centers				,							dim=-1		),
		    bin_centers[-1],
		)


def        A__						(							SCREAMING_SNAKE_CASE_				,							SCREAMING_SNAKE_CASE_ = 3_1				,							SCREAMING_SNAKE_CASE_ = 6_4				,							**SCREAMING_SNAKE_CASE_				,							) ->  Dict[str, torch.Tensor]:
		lowerCamelCase :			List[str]    		=torch.linspace(0				,							SCREAMING_SNAKE_CASE_				,							steps=(no_bins - 1)				,							device=logits.device		)

		lowerCamelCase :			List[str]    		=torch.nn.functional.softmax(SCREAMING_SNAKE_CASE_				,							dim=-1		)
		lowerCamelCase		, lowerCamelCase :			str    		=_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        A__						(							SCREAMING_SNAKE_CASE_				,							SCREAMING_SNAKE_CASE_ = None				,							SCREAMING_SNAKE_CASE_ = 3_1				,							SCREAMING_SNAKE_CASE_ = 6_4				,							SCREAMING_SNAKE_CASE_ = 1E-8				,							**SCREAMING_SNAKE_CASE_				,							) ->  torch.Tensor:
		if residue_weights is None:
				lowerCamelCase :			List[Any]    		=logits.new_ones(logits.shape[-2]		)

		lowerCamelCase :			List[str]    		=torch.linspace(0				,							SCREAMING_SNAKE_CASE_				,							steps=(no_bins - 1)				,							device=logits.device		)

		lowerCamelCase :			str    		=_calculate_bin_centers(SCREAMING_SNAKE_CASE_		)
		torch.sum(SCREAMING_SNAKE_CASE_		)
		lowerCamelCase :			int    		=logits.shape[-2]
		lowerCamelCase :			Optional[Any]    		=max(SCREAMING_SNAKE_CASE_				,							1_9		)

		lowerCamelCase :			Union[str, Any]    		=1.2_4 * (clipped_n - 1_5) ** (1.0 / 3) - 1.8

		lowerCamelCase :			Tuple    		=torch.nn.functional.softmax(SCREAMING_SNAKE_CASE_				,							dim=-1		)

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

		lowerCamelCase :			Tuple    		=residue_weights / (eps + residue_weights.sum())
		lowerCamelCase :			str    		=torch.sum(predicted_tm_term * normed_residue_mask				,							dim=-1		)

		lowerCamelCase :			List[Any]    		=per_alignment * residue_weights

		lowerCamelCase :			Tuple    		=(weighted == torch.max(SCREAMING_SNAKE_CASE_		)).nonzero()[0]
		return per_alignment[tuple(SCREAMING_SNAKE_CASE_		)]








def        A__						(							SCREAMING_SNAKE_CASE_ = 1_0_0_0		) ->  int:
		lowerCamelCase :			Dict    		=[]
		lowerCamelCase :			Dict    		=[]
		lowerCamelCase :			Union[str, Any]    		=3
		lowerCamelCase :			List[str]    		=5
		lowerCamelCase :			Union[str, Any]    		=1
		while True:
				lowerCamelCase :			Dict    		=z * temp
				if result < n:
						zmulti.append(SCREAMING_SNAKE_CASE_		)
						temp += 1
				else:
						lowerCamelCase :			List[Any]    		=1
						break
		while True:
				lowerCamelCase :			Optional[Any]    		=x * temp
				if result < n:
						xmulti.append(SCREAMING_SNAKE_CASE_		)
						temp += 1
				else:
						break
		lowerCamelCase :			str    		=list(set(xmulti + zmulti		)		)
		return sum(SCREAMING_SNAKE_CASE_		)


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

