


from itertools import product
def 							_UpperCAmelCase				(UpperCamelCase__     :  int				,							UpperCamelCase__     :  int						):
       _A      :       Dict				    = sides_number
       _A      :       Any				    = max_face_number * dice_number
       _A      :       Optional[int]				    = [0] * (max_total + 1)

       _A      :       Any				    = 1
       _A      :       str				    = range(UpperCamelCase__				,							max_face_number + 1						)
       for dice_numbers in product(UpperCamelCase__				,							repeat=UpperCamelCase__						):
              _A      :       Tuple				    = sum(UpperCamelCase__						)
              totals_frequencies[total] += 1

       return totals_frequencies
def 							_UpperCAmelCase				():
       _A      :       Any				    = total_frequency_distribution(
           sides_number=4				,							dice_number=9						)
       _A      :       Tuple				    = total_frequency_distribution(
           sides_number=6				,							dice_number=6						)

       _A      :       Any				    = 0
       _A      :       int				    = 9
       _A      :       List[str]				    = 4 * 9
       _A      :       Dict				    = 6
       for peter_total in range(UpperCamelCase__				,							max_peter_total + 1						):
              peter_wins_count += peter_totals_frequencies[peter_total] * sum(
                  colin_totals_frequencies[min_colin_total:peter_total]						)

       _A      :       Dict				    = (4**9) * (6**6)
       _A      :       List[str]				    = peter_wins_count / total_games_number

       _A      :       Dict				    = round(UpperCamelCase__				,							ndigits=7						)

       return rounded_peter_win_probability


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




import re

from flax.core.frozen_dict import freeze
from flax.traverse_util import flatten_dict, unflatten_dict
from jax.experimental import PartitionSpec as P


# Sentinels
lowerCAmelCase__      		= object()

# For specifying empty leaf dict `{}`
lowerCAmelCase__      		= object()
def 							_UpperCAmelCase				(UpperCamelCase__     :  str				,							UpperCamelCase__     :  Union[str, Any]						):
       _A      :       str				    = tuple((re.compile(x + "$"						) for x in qs)						)
       for i in range(len(UpperCamelCase__						) - len(UpperCamelCase__						) + 1						):
              _A      :       Tuple				    = [x.match(UpperCamelCase__						) for x, y in zip(UpperCamelCase__				,							ks[i:]						)]
              if matches and all(UpperCamelCase__						):
                     return True
       return False
def 							_UpperCAmelCase				(UpperCamelCase__     :  str						):
       def replace(UpperCamelCase__     :  List[str]				,							UpperCamelCase__     :  Optional[int]						):
              for rule, replacement in rules:
                     if _match(UpperCamelCase__				,							UpperCamelCase__						):
                            return replacement
              return val

       return replace
def 							_UpperCAmelCase				():
       return [
           # embeddings
           (("transformer", "wpe", "embedding"), P("mp"				,							UpperCamelCase__						)),
           (("transformer", "wte", "embedding"), P("mp"				,							UpperCamelCase__						)),
           # atention
           (("attention", "(q_proj|k_proj|v_proj)", "kernel"), P(UpperCamelCase__				,							"mp"						)),
           (("attention", "out_proj", "kernel"), P("mp"				,							UpperCamelCase__						)),
           (("attention", "out_proj", "bias"), None),
           # mlp
           (("mlp", "c_fc", "kernel"), P(UpperCamelCase__				,							"mp"						)),
           (("mlp", "c_fc", "bias"), P("mp"						)),
           (("mlp", "c_proj", "kernel"), P("mp"				,							UpperCamelCase__						)),
           (("mlp", "c_proj", "bias"), None),
           # layer norms
           ((r"ln_\d+", "bias"), None),
           ((r"\d+", r"ln_\d+", "scale"), None),
           (("ln_f", "bias"), None),
           (("ln_f", "scale"), None),
       ]






def 							_UpperCAmelCase				(UpperCamelCase__     :  List[str]						):
       _A      :       int				    = _get_partition_rules()
       _A      :       Optional[int]				    = _replacement_rules(UpperCamelCase__						)
       _A      :       Optional[int]				    = {k: _unmatched for k in flatten_dict(UpperCamelCase__						)}
       _A      :       List[str]				    = {k: replace(UpperCamelCase__				,							UpperCamelCase__						) for k, v in initd.items()}
       assert _unmatched not in result.values(), "Incomplete partition spec."
       return freeze(unflatten_dict(UpperCamelCase__						)						)
