


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

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


def       a				(      __a			, __a       )  ->     Tuple:



					'''simple docstring'''






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


def       a				(      __a       )  ->     Dict:



					'''simple docstring'''






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

					return replace


def       a				(      )  ->     Tuple:



					'''simple docstring'''






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



					'''simple docstring'''






					UpperCamelCase__       :Tuple							 =			_get_partition_rules()
					UpperCamelCase__       :Any							 =			_replacement_rules(__a       )
					UpperCamelCase__       :List[Any]							 =			{k: _unmatched for k in flatten_dict(__a       )}
					UpperCamelCase__       :Tuple							 =			{k: replace(__a			, __a       ) for k, v in initd.items()}
					assert _unmatched not in result.values(), "Incomplete partition spec."
					return freeze(unflatten_dict(__a       )       )



'''simple docstring'''
import socket


def       a				(      )  ->     Dict:



					'''simple docstring'''






					UpperCamelCase__       :int							 =			socket.socket(socket.AF_INET			, socket.SOCK_STREAM       )
					UpperCamelCase__       :List[Any]							 =			socket.gethostname()
					UpperCamelCase__       :List[str]							 =			12312

					sock.connect((host, port)       )
					sock.send(B'''Hello server!'''       )

					with open('''Received_file'''			, '''wb'''       ) as out_file:
										print('''File opened'''       )
										print('''Receiving data...'''       )
										while True:
															UpperCamelCase__       :str							 =			sock.recv(1024       )
															if not data:
																				break
															out_file.write(__a       )

					print('''Successfully received the file'''       )
					sock.close()
					print('''Connection closed'''       )


if __name__ == "__main__":
		main()