





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
__A							:			Optional[Any]         =			object()

# For specifying empty leaf dict `{}`
__A							:			Union[str, Any]         =			object()





def 				__lowerCAmelCase(       _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)							-> Dict:




    """simple docstring"""




    _A     =							tuple((re.compile(x + '$'				) for x in qs)				)
    for i in range(len(_SCREAMING_SNAKE_CASE				) - len(_SCREAMING_SNAKE_CASE				) + 1				):
        _A     =							[x.match(_SCREAMING_SNAKE_CASE				) for x, y in zip(_SCREAMING_SNAKE_CASE							,     ks[i:]				)]
        if matches and all(_SCREAMING_SNAKE_CASE				):
            return True
    return False





def 				__lowerCAmelCase(       _SCREAMING_SNAKE_CASE				)							-> Optional[int]:




    """simple docstring"""




    def replace(_SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				):
        for rule, replacement in rules:
            if _match(_SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				):
                return replacement
        return val

    return replace





def 				__lowerCAmelCase(       )							-> int:




    """simple docstring"""




    return [
        # embeddings
        (("transformer", "wpe", "embedding"), P('mp'							,     _SCREAMING_SNAKE_CASE				)),
        (("transformer", "wte", "embedding"), P('mp'							,     _SCREAMING_SNAKE_CASE				)),
        # atention
        (("attention", "(q_proj|k_proj|v_proj)", "kernel"), P(_SCREAMING_SNAKE_CASE							,     'mp'				)),
        (("attention", "out_proj", "kernel"), P('mp'							,     _SCREAMING_SNAKE_CASE				)),
        (("attention", "out_proj", "bias"), None),
        # mlp
        (("mlp", "c_fc", "kernel"), P(_SCREAMING_SNAKE_CASE							,     'mp'				)),
        (("mlp", "c_fc", "bias"), P('mp'				)),
        (("mlp", "c_proj", "kernel"), P('mp'							,     _SCREAMING_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 				__lowerCAmelCase(       _SCREAMING_SNAKE_CASE				)							-> Optional[int]:




    """simple docstring"""




    _A     =							_get_partition_rules()
    _A     =							_replacement_rules(_SCREAMING_SNAKE_CASE				)
    _A     =							{k: _unmatched for k in flatten_dict(_SCREAMING_SNAKE_CASE				)}
    _A     =							{k: replace(_SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				) for k, v in initd.items()}
    assert _unmatched not in result.values(), "Incomplete partition spec."
    return freeze(unflatten_dict(_SCREAMING_SNAKE_CASE				)				)












def 				__lowerCAmelCase(       _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)							-> float:




    """simple docstring"""




    return price * (1 + tax_rate)


if __name__ == "__main__":
 print(f"{price_plus_tax(100, 0.2_5) = }")
 print(f"{price_plus_tax(1_2_5.5_0, 0.0_5) = }")





