




'''simple docstring'''







def 						snake_case_							(_a	:							List[str]    ,   _a	:							int     ):
    return abs(_a     ) if a == 0 else greatest_common_divisor(b % a    ,   _a     )





def 						snake_case_							(_a	:							List[str]    ,   _a	:							str     ):
    while y:  # --> when y=0 then loop will terminate and return x as final GCD.
        UpperCAmelCase       ,     UpperCAmelCase			       =		y, x % y
    return abs(_a     )





def 						snake_case_							():
    try:
        UpperCAmelCase			       =		input('''Enter two integers separated by comma (,): '''     ).split(''','''     )
        UpperCAmelCase			       =		int(nums[0]     )
        UpperCAmelCase			       =		int(nums[1]     )
        print(
            F"greatest_common_divisor({num_a}, {num_a}) = "
            F"{greatest_common_divisor(_a    ,   _a     )}"     )
        print(F"By iterative gcd({num_a}, {num_a}) = {gcd_by_iterative(_a    ,   _a     )}"     )
    except (IndexError, UnboundLocalError, ValueError):
        print('''Wrong input'''     )


if __name__ == "__main__":
   main()





"""simple docstring"""






import os

import numpy
import onnx



def   a_						(					lowerCamelCase					,			lowerCamelCase       ):
				UpperCAmelCase__             =							a.name
				UpperCAmelCase__             =							b.name

				UpperCAmelCase__             =							''
				UpperCAmelCase__             =							''

				UpperCAmelCase__             =							a == b

				UpperCAmelCase__             =							name_a
				UpperCAmelCase__             =							name_b

				return res



def   a_						(					lowerCamelCase					,			lowerCamelCase					,			lowerCamelCase       ):
				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					,			lowerCamelCase					,			lowerCamelCase       ):
				for n in graph_proto.node:
								_node_replace_input_with(lowerCamelCase					,			lowerCamelCase					,			lowerCamelCase       )



def   a_						(					lowerCamelCase					,			lowerCamelCase					,			lowerCamelCase       ):
				UpperCAmelCase__             =							list(model.graph.initializer       )
				UpperCAmelCase__             =							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

								UpperCAmelCase__             =							inits[i].name
								UpperCAmelCase__             =							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       ):
				UpperCAmelCase__             =							os.path.dirname(lowerCamelCase       )
				UpperCAmelCase__             =							os.path.basename(lowerCamelCase       )

				UpperCAmelCase__             =							onnx.load(os.path.join(lowerCamelCase					,			lowerCamelCase       )       )

				UpperCAmelCase__             =							list(model.graph.initializer       )

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

				UpperCAmelCase__             =							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       )

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

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

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

				print('total reduced size: '					,			total_reduced_size / 1_0_2_4 / 1_0_2_4 / 1_0_2_4					,			'GB'       )

				UpperCAmelCase__             =							sorted(lowerCamelCase       )
				_remove_dup_initializers_from_model(lowerCamelCase					,			lowerCamelCase					,			lowerCamelCase       )

				UpperCAmelCase__             =							'optimized_' + model_file_name
				UpperCAmelCase__             =							os.path.join(lowerCamelCase					,			lowerCamelCase       )
				onnx.save(lowerCamelCase					,			lowerCamelCase       )

				return new_model



