


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

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







def       _UpperCamelCase (						UpperCamelCase__	, UpperCamelCase__   ):
   UpperCAmelCase__					:   str       				=       tuple((re.compile(x + """$"""   ) for x in qs)   )
   for i in range(len(lowerCAmelCase__   ) - len(lowerCAmelCase__   ) + 1   ):
      UpperCAmelCase__					:   int       				=       [x.match(lowerCAmelCase__   ) for x, y in zip(lowerCAmelCase__	, ks[i:]   )]
      if matches and all(lowerCAmelCase__   ):
         return True
   return False







def       _UpperCamelCase (						UpperCamelCase__   ):
   def replace(UpperCamelCase__	, UpperCamelCase__   ):
      for rule, replacement in rules:
         if _match(lowerCAmelCase__	, lowerCAmelCase__   ):
            return replacement
      return val

   return replace







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



'''simple docstring'''



def       _UpperCamelCase (						UpperCamelCase__ = 4_0_0_0_0_0_0   ):
			UpperCAmelCase__					:   List[str]       				=       [0, 1]
			UpperCAmelCase__					:   Any       				=       0
			while fib[i] <= n:
						fib.append(fib[i] + fib[i + 1]   )
						if fib[i + 2] > n:
									break
						i += 1
			UpperCAmelCase__					:   str       				=       0
			for j in range(len(UpperCamelCase__   ) - 1   ):
						if fib[j] % 2 == 0:
									total += fib[j]

			return total


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