






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
__UpperCAmelCase								=						object()

# For specifying empty leaf dict `{}`
__UpperCAmelCase								=						object()




def      lowercase__      (     __snake_case    :							List[Any]     ,       __snake_case    :							Optional[int]  ):


					'''simple docstring'''


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




def      lowercase__      (     __snake_case    :							Optional[Any]  ):


					'''simple docstring'''


					def replace(__snake_case    :							List[Any]     ,       __snake_case    :							Optional[Any]  ):
										for rule, replacement in rules:
															if _match(__snake_case     ,       __snake_case  ):
																				return replacement
										return val

					return replace




def      lowercase__      (     ):


					'''simple docstring'''


					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      lowercase__      (     __snake_case    :							List[Any]  ):


					'''simple docstring'''


					UpperCAmelCase_    :      Dict            =						_get_partition_rules()
					UpperCAmelCase_    :      Optional[Any]            =						_replacement_rules(__snake_case  )
					UpperCAmelCase_    :      Dict            =						{k: _unmatched for k in flatten_dict(__snake_case  )}
					UpperCAmelCase_    :      Optional[Any]            =						{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  )  )










UpperCAmelCase_      : Optional[int]  					=       [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]
UpperCAmelCase_      : str  					=       [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]
UpperCAmelCase_      : str  					=       {
    0: 'Sunday',
    1: 'Monday',
    2: 'Tuesday',
    3: 'Wednesday',
    4: 'Thursday',
    5: 'Friday',
    6: 'Saturday',
}







def        SCREAMING_SNAKE_CASE_						(			__A :			int  ,    __A :			int  ,    __A :			int				)	->		str:

       """simple docstring"""

       assert len(str(__A				)				) > 2, "year should be in YYYY format"
       assert 1 <= month <= 12, "month should be between 1 to 12"
       assert 1 <= day <= 31, "day should be between 1 to 31"

       # Doomsday algorithm:
       a_					:		List[str]							=  year // 1_00
       a_					:		Optional[int]							=  (5 * (century % 4) + 2) % 7
       a_					:		List[str]							=  year % 1_00
       a_					:		str							=  centurian % 12
       a_					:		List[str]							=  (
           (centurian // 12) + centurian_m + (centurian_m // 4) + century_anchor
       ) % 7
       a_					:		Any							=  (
           DOOMSDAY_NOT_LEAP[month - 1]
           if (year % 4 != 0) or (centurian == 0 and (year % 4_00) == 0)
           else DOOMSDAY_LEAP[month - 1]
       )
       a_					:		Any							=  (dooms_day + day - day_anchor) % 7
       return WEEK_DAY_NAMES[week_day]


if __name__ == "__main__":
   import doctest

   doctest.testmod()


