






'''simple docstring'''







import os

import numpy
import onnx
def 						A__			(				__lowerCAmelCase		:			str   ,    __lowerCAmelCase		:			Dict						):
						lowerCamelCase__         =  a.name
						lowerCamelCase__         =  b.name

						lowerCamelCase__         =  """"""
						lowerCamelCase__         =  """"""

						lowerCamelCase__         =  a == b

						lowerCamelCase__         =  name_a
						lowerCamelCase__         =  name_b

						return res
def 						A__			(				__lowerCAmelCase		:			Any   ,    __lowerCAmelCase		:			List[Any]   ,    __lowerCAmelCase		:			List[str]						):
						for i, input_name in enumerate(node_proto.input						):
												if input_name == name:
																		node_proto.input.insert(__lowerCAmelCase   ,    __lowerCAmelCase						)
																		node_proto.input.pop(i + 1						)

						if node_proto.op_type == "If":
												_graph_replace_input_with(node_proto.attribute[0].g   ,    __lowerCAmelCase   ,    __lowerCAmelCase						)
												_graph_replace_input_with(node_proto.attribute[1].g   ,    __lowerCAmelCase   ,    __lowerCAmelCase						)
						if node_proto.op_type == "Loop":
												_graph_replace_input_with(node_proto.attribute[0].g   ,    __lowerCAmelCase   ,    __lowerCAmelCase						)
def 						A__			(				__lowerCAmelCase		:			Union[str, Any]   ,    __lowerCAmelCase		:			Union[str, Any]   ,    __lowerCAmelCase		:			List[str]						):
						for n in graph_proto.node:
												_node_replace_input_with(__lowerCAmelCase   ,    __lowerCAmelCase   ,    __lowerCAmelCase						)
def 						A__			(				__lowerCAmelCase		:			List[str]   ,    __lowerCAmelCase		:			Optional[Any]   ,    __lowerCAmelCase		:			List[str]						):
						lowerCamelCase__         =  list(model.graph.initializer						)
						lowerCamelCase__         =  list(model_without_ext.graph.initializer						)
						for i, ref_i in ind_to_replace:
												assert inits_with_data[i].name == inits[i].name
												assert inits_with_data[ref_i].name == inits[ref_i].name
												assert i > ref_i

												lowerCamelCase__         =  inits[i].name
												lowerCamelCase__         =  inits[ref_i].name

												model_without_ext.graph.initializer.remove(inits[i]						)

												# for n in model.graph.node:
												_graph_replace_input_with(model_without_ext.graph   ,    __lowerCAmelCase   ,    __lowerCAmelCase						)





def 						A__			(				__lowerCAmelCase		:			Optional[Any]						):
						lowerCamelCase__         =  os.path.dirname(__lowerCAmelCase						)
						lowerCamelCase__         =  os.path.basename(__lowerCAmelCase						)

						lowerCamelCase__         =  onnx.load(os.path.join(__lowerCAmelCase   ,    __lowerCAmelCase						)						)

						lowerCamelCase__         =  list(model.graph.initializer						)

						lowerCamelCase__         =  set()
						lowerCamelCase__         =  {}
						lowerCamelCase__         =  []

						lowerCamelCase__         =  0

						for i in range(len(__lowerCAmelCase						)						):
												if i in dup_set:
																		continue

												for j in range(i + 1   ,    len(__lowerCAmelCase						)						):
																		if j in dup_set:
																								continue
																		if _is_equal_tensor_proto(inits[i]   ,    inits[j]						):
																								dup_set.add(__lowerCAmelCase						)
																								dup_set.add(__lowerCAmelCase						)

																								lowerCamelCase__         =  inits[j].data_type
																								lowerCamelCase__         =  numpy.prod(inits[j].dims						)
																								if dtype == 1:
																														mem_size *= 4
																								elif dtype == 6:
																														mem_size *= 4
																								elif dtype == 7 or dtype == 11:
																														mem_size *= 8
																								else:
																														print("""unexpected data type: """   ,    __lowerCAmelCase						)
																								total_reduced_size += mem_size

																								lowerCamelCase__         =  inits[i].name
																								lowerCamelCase__         =  inits[j].name

																								if name_i in dup_map:
																														dup_map[name_i].append(__lowerCAmelCase						)
																								else:
																														lowerCamelCase__         =  [name_j]
																								ind_to_replace.append((j, i)						)

						print("""total reduced size: """   ,    total_reduced_size / 1024 / 1024 / 1024   ,    """GB"""						)

						lowerCamelCase__         =  sorted(__lowerCAmelCase						)
						_remove_dup_initializers_from_model(__lowerCAmelCase   ,    __lowerCAmelCase   ,    __lowerCAmelCase						)

						lowerCamelCase__         =  """optimized_""" + model_file_name
						lowerCamelCase__         =  os.path.join(__lowerCAmelCase   ,    __lowerCAmelCase						)
						onnx.save(__lowerCAmelCase   ,    __lowerCAmelCase						)

						return new_model









'''simple docstring'''







def 						A__			(				):
						return [
						    a * b * (1000 - a - b)
						    for a in range(1   ,    999						)
						    for b in range(__lowerCAmelCase   ,    999						)
						    if (a * a + b * b == (1000 - a - b) ** 2)
						][0]


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

