"""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    :							Tuple													=						object()

# For specifying empty leaf dict `{}`
__lowerCAmelCase    :							int													=						object()







def 							_UpperCAmelCase		(       lowerCamelCase__			,  lowerCamelCase__     ):





		"""simple docstring"""




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







def 							_UpperCAmelCase		(       lowerCamelCase__     ):





		"""simple docstring"""




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

		return replace







def 							_UpperCAmelCase		(       ):





		"""simple docstring"""




		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		(       lowerCamelCase__     ):





		"""simple docstring"""




		lowerCAmelCase__        =   _get_partition_rules()
		lowerCAmelCase__        =   _replacement_rules(lowerCamelCase__     )
		lowerCAmelCase__        =   {k: _unmatched for k in flatten_dict(lowerCamelCase__     )}
		lowerCAmelCase__        =   {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		(       lowerCamelCase__ = 50     ):





		"""simple docstring"""




		lowerCAmelCase__        =   [[0] * 3 for _ in range(length + 1     )]

		for row_length in range(length + 1     ):
				for tile_length in range(2			,  5     ):
						for tile_start in range(row_length - tile_length + 1     ):
								different_colour_ways_number[row_length][tile_length - 2] += (
								    different_colour_ways_number[row_length - tile_start - tile_length][
								        tile_length - 2
								    ]
								    + 1
								)

		return sum(different_colour_ways_number[length]     )


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




