def 					snake_case    (			snake_case__     :str)		->  int:
       _A	  =    abs(snake_case__)
       _A	  =    0
       while n > 0:
              res += n % 10
              n //= 10
       return res






def 					snake_case    (			snake_case__     :str)		->  int:
       _A	  =    abs(snake_case__)
       return n if n < 10 else n % 10 + sum_of_digits(n // 10)






def 					snake_case    (			snake_case__     :Any)		->  int:
       return sum(int(snake_case__) for c in str(abs(snake_case__)))






def 					snake_case    (			)		->  None:
       from collections.abc import Callable
       from timeit import timeit

       def benchmark_a_function(snake_case__     :List[Any]  ,      snake_case__     :List[str]) -> None:
              _A	  =    F'''{func.__name__}({value})'''
              _A	  =    timeit(F'''__main__.{call}'''  ,      setup="""import __main__""")
              print(F'''{call:56} = {func(snake_case__)} -- {timing:.4f} seconds''')

       for value in (262_144, 1_125_899_906_842_624, 1_267_650_600_228_229_401_496_703_205_376):
              for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
                     benchmark_a_function(snake_case__  ,      snake_case__)
              print()


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    benchmark()










"""simple docstring"""




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				:     List[str]					=				object()

# For specifying empty leaf dict `{}`
lowerCAmelCase				:     Any					=				object()



def        a__					(							snake_case__			,					snake_case__							)		->   List[Any]:
			lowerCamelCase      =   tuple((re.compile(x + """$"""							) for x in qs)							)
			for i in range(len(snake_case__							) - len(snake_case__							) + 1							):
						lowerCamelCase      =   [x.match(snake_case__							) for x, y in zip(snake_case__			,					ks[i:]							)]
						if matches and all(snake_case__							):
									return True
			return False



def        a__					(							snake_case__							)		->   str:
			def replace(snake_case__			,					snake_case__							):
						for rule, replacement in rules:
									if _match(snake_case__			,					snake_case__							):
												return replacement
						return val

			return replace



def        a__					(							)		->   Union[str, Any]:
			return [
			    # embeddings
			    (("transformer", "wpe", "embedding"), P("""mp"""			,					snake_case__							)),
			    (("transformer", "wte", "embedding"), P("""mp"""			,					snake_case__							)),
			    # atention
			    (("attention", "(q_proj|k_proj|v_proj)", "kernel"), P(snake_case__			,					"""mp"""							)),
			    (("attention", "out_proj", "kernel"), P("""mp"""			,					snake_case__							)),
			    (("attention", "out_proj", "bias"), None),
			    # mlp
			    (("mlp", "c_fc", "kernel"), P(snake_case__			,					"""mp"""							)),
			    (("mlp", "c_fc", "bias"), P("""mp"""							)),
			    (("mlp", "c_proj", "kernel"), P("""mp"""			,					snake_case__							)),
			    (("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        a__					(							snake_case__							)		->   Optional[Any]:
			lowerCamelCase      =   _get_partition_rules()
			lowerCamelCase      =   _replacement_rules(snake_case__							)
			lowerCamelCase      =   {k: _unmatched for k in flatten_dict(snake_case__							)}
			lowerCamelCase      =   {k: replace(snake_case__			,					snake_case__							) for k, v in initd.items()}
			assert _unmatched not in result.values(), "Incomplete partition spec."
			return freeze(unflatten_dict(snake_case__							)							)



