





'''simple docstring'''





import os

import numpy
import onnx





def    __UpperCamelCase      (    a,     a) ->int:
					lowerCamelCase__       =       a.name
					lowerCamelCase__       =       b.name

					lowerCamelCase__       =       ""
					lowerCamelCase__       =       ""

					lowerCamelCase__       =       a == b

					lowerCamelCase__       =       name_a
					lowerCamelCase__       =       name_b

					return res





def    __UpperCamelCase      (    a,     a,     a) ->Any:
					for i, input_name in enumerate(node_proto.input):
										if input_name == name:
															node_proto.input.insert(a,     a)
															node_proto.input.pop(i + 1)

					if node_proto.op_type == "If":
										_graph_replace_input_with(node_proto.attribute[0].g,     a,     a)
										_graph_replace_input_with(node_proto.attribute[1].g,     a,     a)
					if node_proto.op_type == "Loop":
										_graph_replace_input_with(node_proto.attribute[0].g,     a,     a)





def    __UpperCamelCase      (    a,     a,     a) ->List[str]:
					for n in graph_proto.node:
										_node_replace_input_with(a,     a,     a)





def    __UpperCamelCase      (    a,     a,     a) ->Tuple:
					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,     a,     a)







def    __UpperCamelCase      (    a) ->Dict:
					lowerCamelCase__       =       os.path.dirname(a)
					lowerCamelCase__       =       os.path.basename(a)

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

					lowerCamelCase__       =       list(model.graph.initializer)

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

					lowerCamelCase__       =       0

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

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

																				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: ",     a)
																				total_reduced_size += mem_size

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

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

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

					lowerCamelCase__       =       sorted(a)
					_remove_dup_initializers_from_model(a,     a,     a)

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

					return new_model








def    __UpperCamelCase      (    a = 100) ->int:
					lowerCamelCase__       =       (n * (n + 1) // 2) ** 2
					lowerCamelCase__       =       n * (n + 1) * (2 * n + 1) // 6
					return sum_cubes - sum_squares


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

