






"""simple docstring"""







from typing import Dict, Optional, Tuple

import torch






def 					_lowerCAmelCase				(					lowerCAmelCase						):







       '''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				(					lowerCAmelCase		,					lowerCAmelCase		,					):







       '''simple docstring'''
       UpperCAmelCase					=	_calculate_bin_centers(lowerCAmelCase						)
       return (
           torch.sum(aligned_distance_error_probs * bin_centers		,					dim=-1						),
           bin_centers[-1],
       )






def 					_lowerCAmelCase				(					lowerCAmelCase		,					lowerCAmelCase = 31		,					lowerCAmelCase = 64		,					**lowerCAmelCase		,					):







       '''simple docstring'''
       UpperCAmelCase					=	torch.linspace(0		,					lowerCAmelCase		,					steps=(no_bins - 1)		,					device=logits.device						)

       UpperCAmelCase					=	torch.nn.functional.softmax(lowerCAmelCase		,					dim=-1						)
       UpperCAmelCase			,				UpperCAmelCase					=	_calculate_expected_aligned_error(
           alignment_confidence_breaks=lowerCAmelCase		,					aligned_distance_error_probs=lowerCAmelCase		,					)

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






def 					_lowerCAmelCase				(					lowerCAmelCase		,					lowerCAmelCase = None		,					lowerCAmelCase = 31		,					lowerCAmelCase = 64		,					lowerCAmelCase = 1e-8		,					**lowerCAmelCase		,					):







       '''simple docstring'''
       if residue_weights is None:
              UpperCAmelCase					=	logits.new_ones(logits.shape[-2]						)

       UpperCAmelCase					=	torch.linspace(0		,					lowerCAmelCase		,					steps=(no_bins - 1)		,					device=logits.device						)

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

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

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








"""simple docstring"""







import unittest
from timeit import timeit






def 					_lowerCAmelCase				(					lowerCAmelCase		,					lowerCAmelCase						):







       '''simple docstring'''
       UpperCAmelCase					=	first_num if first_num >= second_num else second_num
       UpperCAmelCase					=	max_num
       while (common_mult % first_num > 0) or (common_mult % second_num > 0):
              common_mult += max_num
       return common_mult






def 					_lowerCAmelCase				(					lowerCAmelCase		,					lowerCAmelCase						):







       '''simple docstring'''
       return b if a == 0 else greatest_common_divisor(b % a		,					lowerCAmelCase						)






def 					_lowerCAmelCase				(					lowerCAmelCase		,					lowerCAmelCase						):







       '''simple docstring'''
       return first_num // greatest_common_divisor(lowerCAmelCase		,					lowerCAmelCase						) * second_num






def 					_lowerCAmelCase				(					):







       '''simple docstring'''
       UpperCAmelCase					=	(
           """from __main__ import least_common_multiple_slow, least_common_multiple_fast"""
       )
       print(
           """least_common_multiple_slow():"""		,					timeit("""least_common_multiple_slow(1000, 999)"""		,					setup=lowerCAmelCase						)		,					)
       print(
           """least_common_multiple_fast():"""		,					timeit("""least_common_multiple_fast(1000, 999)"""		,					setup=lowerCAmelCase						)		,					)





class      UpperCamelCase_       (				unittest.TestCase     ):
  _A				:    List[str] =		(
      (10, 20),
      (13, 15),
      (4, 31),
      (10, 42),
      (43, 34),
      (5, 12),
      (12, 25),
      (10, 25),
      (6, 9),
  )
  _A				:    int =		(20, 195, 124, 210, 1462, 60, 300, 50, 18)



  def 						UpperCamelCase_ (					self )	->	Any:



         """simple docstring"""





         for i, (first_num, second_num) in enumerate(self.test_inputs ):
                UpperCAmelCase					=	least_common_multiple_slow(snake_case__       ,						snake_case__ )
                UpperCAmelCase					=	least_common_multiple_fast(snake_case__       ,						snake_case__ )
                with self.subTest(i=snake_case__ ):
                       self.assertEqual(snake_case__       ,						self.expected_results[i] )
                       self.assertEqual(snake_case__       ,						self.expected_results[i] )


if __name__ == "__main__":
 benchmark()
 unittest.main()
