





"""simple docstring"""






import inspect
import os
import unittest

import torch

import accelerate
from accelerate import debug_launcher
from accelerate.test_utils import (
    execute_subprocess_async,
    require_cpu,
    require_huggingface_suite,
    require_multi_gpu,
    require_single_gpu,
)
from accelerate.utils import patch_environment



@require_huggingface_suite
class 	lowerCAmelCase					(      unittest.TestCase							):

       '''simple docstring'''





       def 							__A (   self     ):
              _UpperCAmelCase     =     inspect.getfile(accelerate.test_utils     )
              _UpperCAmelCase     =     os.path.sep.join(
                  mod_file.split(os.path.sep     )[:-1] + ['scripts', 'external_deps', 'test_metrics.py']     )

              from accelerate.test_utils.scripts.external_deps import test_metrics  # noqa: F401

              _UpperCAmelCase     =     test_metrics






       @require_cpu
       def 							__A (   self     ):
              debug_launcher(self.test_metrics.main    ,  num_processes=1     )






       @require_cpu
       def 							__A (   self     ):
              debug_launcher(self.test_metrics.main     )






       @require_single_gpu
       def 							__A (   self     ):
              self.test_metrics.main()






       @require_multi_gpu
       def 							__A (   self     ):
              print(f"""Found {torch.cuda.device_count()} devices."""     )
              _UpperCAmelCase     =     ["torchrun", f"""--nproc_per_node={torch.cuda.device_count()}""", self.test_file_path]
              with patch_environment(omp_num_threads=1     ):
                     execute_subprocess_async(lowerCAmelCase__    ,  env=os.environ.copy()     )













"""simple docstring"""






from itertools import product

def       __lowerCamelCase    (       SCREAMING_SNAKE_CASE,SCREAMING_SNAKE_CASE							)		->       list[int]:






       """simple docstring"""




       _UpperCAmelCase     =     sides_number
       _UpperCAmelCase     =     max_face_number * dice_number
       _UpperCAmelCase     =     [0] * (max_total + 1)

       _UpperCAmelCase     =     1
       _UpperCAmelCase     =     range(SCREAMING_SNAKE_CASE,max_face_number + 1							)
       for dice_numbers in product(SCREAMING_SNAKE_CASE,repeat=SCREAMING_SNAKE_CASE							):
              _UpperCAmelCase     =     sum(SCREAMING_SNAKE_CASE							)
              totals_frequencies[total] += 1

       return totals_frequencies

def       __lowerCamelCase    (       )		->       float:






       """simple docstring"""




       _UpperCAmelCase     =     total_frequency_distribution(
           sides_number=4,dice_number=9							)
       _UpperCAmelCase     =     total_frequency_distribution(
           sides_number=6,dice_number=6							)

       _UpperCAmelCase     =     0
       _UpperCAmelCase     =     9
       _UpperCAmelCase     =     4 * 9
       _UpperCAmelCase     =     6
       for peter_total in range(SCREAMING_SNAKE_CASE,max_peter_total + 1							):
              peter_wins_count += peter_totals_frequencies[peter_total] * sum(
                  colin_totals_frequencies[min_colin_total:peter_total]							)

       _UpperCAmelCase     =     (4**9) * (6**6)
       _UpperCAmelCase     =     peter_wins_count / total_games_number

       _UpperCAmelCase     =     round(SCREAMING_SNAKE_CASE,ndigits=7							)

       return rounded_peter_win_probability


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






