





import os

import numpy
import onnx


def       UpperCamelCase__(			UpperCamelCase__     :			Optional[Any]					,	UpperCamelCase__     :			Tuple    )->List[Any]:
       A__		   =		a.name
       A__		   =		b.name

       A__		   =		''''''
       A__		   =		''''''

       A__		   =		a == b

       A__		   =		name_a
       A__		   =		name_b

       return res


def       UpperCamelCase__(			UpperCamelCase__     :			str					,	UpperCamelCase__     :			Union[str, Any]					,	UpperCamelCase__     :			Optional[Any]    )->Tuple:
       for i, input_name in enumerate(node_proto.input    ):
              if input_name == name:
                     node_proto.input.insert(UpperCamelCase__					,	UpperCamelCase__    )
                     node_proto.input.pop(i + 1    )

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


def       UpperCamelCase__(			UpperCamelCase__     :			Optional[Any]					,	UpperCamelCase__     :			int					,	UpperCamelCase__     :			Any    )->int:
       for n in graph_proto.node:
              _node_replace_input_with(UpperCamelCase__					,	UpperCamelCase__					,	UpperCamelCase__    )


def       UpperCamelCase__(			UpperCamelCase__     :			Any					,	UpperCamelCase__     :			Optional[Any]					,	UpperCamelCase__     :			Tuple    )->Tuple:
       A__		   =		list(model.graph.initializer    )
       A__		   =		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

              A__		   =		inits[i].name
              A__		   =		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					,	UpperCamelCase__					,	UpperCamelCase__    )


def       UpperCamelCase__(			UpperCamelCase__     :			Tuple    )->str:
       A__		   =		os.path.dirname(UpperCamelCase__    )
       A__		   =		os.path.basename(UpperCamelCase__    )

       A__		   =		onnx.load(os.path.join(UpperCamelCase__					,	UpperCamelCase__    )    )

       A__		   =		list(model.graph.initializer    )

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

       A__		   =		0

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

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

                            A__		   =		inits[j].data_type
                            A__		   =		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: '''					,	UpperCamelCase__    )
                            total_reduced_size += mem_size

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

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

       print('''total reduced size: '''					,	total_reduced_size / 10_24 / 10_24 / 10_24					,	'''GB'''    )

       A__		   =		sorted(UpperCamelCase__    )
       _remove_dup_initializers_from_model(UpperCamelCase__					,	UpperCamelCase__					,	UpperCamelCase__    )

       A__		   =		'''optimized_''' + model_file_name
       A__		   =		os.path.join(UpperCamelCase__					,	UpperCamelCase__    )
       onnx.save(UpperCamelCase__					,	UpperCamelCase__    )

       return new_model












import math


def       UpperCamelCase__(			UpperCamelCase__     :			int    )->list:
       A__		   =		[True] * n
       A__		   =		False
       A__		   =		False
       A__		   =		True

       for i in range(3					,	int(n**0.5 + 1    )					,	2    ):
              A__		   =		i * 2
              while index < n:
                     A__		   =		False
                     A__		   =		index + i

       A__		   =		[2]

       for i in range(3					,	UpperCamelCase__					,	2    ):
              if is_prime[i]:
                     primes.append(UpperCamelCase__    )

       return primes


def       UpperCamelCase__(			UpperCamelCase__     :			int = 99_99_66_66_33_33    )->int:
       A__		   =		math.floor(math.sqrt(UpperCamelCase__    )    ) + 1_00
       A__		   =		prime_sieve(UpperCamelCase__    )

       A__		   =		0
       A__		   =		0
       A__		   =		primes[prime_index]

       while (last_prime**2) <= limit:
              A__		   =		primes[prime_index + 1]

              A__		   =		last_prime**2
              A__		   =		next_prime**2

              # Get numbers divisible by lps(current)
              A__		   =		lower_bound + last_prime
              while upper_bound > current <= limit:
                     matches_sum += current
                     current += last_prime

              # Reset the upper_bound
              while (upper_bound - next_prime) > limit:
                     upper_bound -= next_prime

              # Add the numbers divisible by ups(current)
              A__		   =		upper_bound - next_prime
              while current > lower_bound:
                     matches_sum += current
                     current -= next_prime

              # Remove the numbers divisible by both ups and lps
              A__		   =		0
              while upper_bound > current <= limit:
                     if current <= lower_bound:
                            # Increment the current number
                            current += last_prime * next_prime
                            continue

                     if current > limit:
                            break

                     # Remove twice since it was added by both ups and lps
                     matches_sum -= current * 2

                     # Increment the current number
                     current += last_prime * next_prime

              # Setup for next pair
              A__		   =		next_prime
              prime_index += 1

       return matches_sum


if __name__ == "__main__":
       print(solution())





