


from typing import Dict, Optional, Tuple

import torch



def 			_a      (    __UpperCamelCase			):
     a_     :  Any				      =     boundaries[1] - boundaries[0]
     a_     :  List[Any]				      =     boundaries + step / 2
     a_     :  Tuple				      =     torch.cat([bin_centers, (bin_centers[-1] + step).unsqueeze(-1			)]	,	dim=0			)
     return bin_centers



def 			_a      (    __UpperCamelCase	,	__UpperCamelCase	,	):
     a_     :  Union[str, Any]				      =     _calculate_bin_centers(__UpperCamelCase			)
     return (
         torch.sum(aligned_distance_error_probs * bin_centers	,	dim=-1			),
         bin_centers[-1],
     )



def 			_a      (    __UpperCamelCase	,	__UpperCamelCase = 3_1	,	__UpperCamelCase = 6_4	,	**__UpperCamelCase	,	):
     a_     :  Tuple				      =     torch.linspace(0	,	__UpperCamelCase	,	steps=(no_bins - 1)	,	device=logits.device			)

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

     a_     :  List[Any]				      =     torch.linspace(0	,	__UpperCamelCase	,	steps=(no_bins - 1)	,	device=logits.device			)

     a_     :  Dict				      =     _calculate_bin_centers(__UpperCamelCase			)
     torch.sum(__UpperCamelCase			)
     a_     :  Union[str, Any]				      =     logits.shape[-2]
     a_     :  Union[str, Any]				      =     max(__UpperCamelCase	,	1_9			)

     a_     :  List[str]				      =     1.24 * (clipped_n - 1_5) ** (1.0 / 3) - 1.8

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

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

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

     a_     :  str				      =     per_alignment * residue_weights

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








from __future__ import annotations





def     __lowerCamelCase							(   __magic_name__						:	int    ):
							for r in range(1  ,			__magic_name__    ):
														a__:							List[str]									=[]
														for x in range(n - 1    ):
																					a__:							int									=pow(__magic_name__  ,			__magic_name__  ,			__magic_name__    )
																					if val in li:
																												break
																					li.append(__magic_name__    )
														else:
																					return r
							return None


if __name__ == "__main__":
		__UpperCAmelCase    	=  int(input('''Enter a prime number q: '''))
		__UpperCAmelCase    	=  find_primitive(q)
		if a is None:
				print(f"""Cannot find the primitive for the value: {a!r}""")
		else:
				__UpperCAmelCase    	=  int(input('''Enter private key of A: '''))
				__UpperCAmelCase    	=  pow(a, a_private, q)
				__UpperCAmelCase    	=  int(input('''Enter private key of B: '''))
				__UpperCAmelCase    	=  pow(a, b_private, q)

				__UpperCAmelCase    	=  pow(b_public, a_private, q)
				__UpperCAmelCase    	=  pow(a_public, b_private, q)

				print('''The key value generated by A is: ''', a_secret)
				print('''The key value generated by B is: ''', b_secret)





