'''simple docstring'''





import math





def      lowerCAmelCase_    ( snake_case_	:			int      )   ->				bool:


     '''simple docstring'''




     if 1 < number < 4:
          # 2 and 3 are primes
          return True
     elif number < 2 or number % 2 == 0 or number % 3 == 0:
          # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
          return False

     # All primes number are in format of 6k +/- 1
     for i in range(5 ,   int(math.sqrt(snake_case_      ) + 1      ) ,   6      ):
          if number % i == 0 or number % (i + 2) == 0:
               return False
     return True





def      lowerCAmelCase_    ( snake_case_	:			int = 1_00_01      )   ->				int:


     '''simple docstring'''




     try:
          UpperCAmelCase_	   =       int(snake_case_      )
     except (TypeError, ValueError):
          raise TypeError("Parameter nth must be int or castable to int."      ) from None
     if nth <= 0:
          raise ValueError("Parameter nth must be greater than or equal to one."      )
     UpperCAmelCase_	   =       []
     UpperCAmelCase_	   =       2
     while len(snake_case_      ) < nth:
          if is_prime(snake_case_      ):
               primes.append(snake_case_      )
               num += 1
          else:
               num += 1
     return primes[len(snake_case_      ) - 1]


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





'''simple docstring'''





import os

import numpy
import onnx





def      lowerCAmelCase_    ( snake_case_	:			Union[str, Any] ,   snake_case_	:			Optional[int]      )   ->				Optional[Any]:


     '''simple docstring'''




     UpperCAmelCase_	   =       a.name
     UpperCAmelCase_	   =       b.name

     UpperCAmelCase_	   =       ""
     UpperCAmelCase_	   =       ""

     UpperCAmelCase_	   =       a == b

     UpperCAmelCase_	   =       name_a
     UpperCAmelCase_	   =       name_b

     return res





def      lowerCAmelCase_    ( snake_case_	:			Any ,   snake_case_	:			Tuple ,   snake_case_	:			Union[str, Any]      )   ->				Any:


     '''simple docstring'''




     for i, input_name in enumerate(node_proto.input      ):
          if input_name == name:
               node_proto.input.insert(snake_case_ ,   snake_case_      )
               node_proto.input.pop(i + 1      )

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





def      lowerCAmelCase_    ( snake_case_	:			List[str] ,   snake_case_	:			List[str] ,   snake_case_	:			Union[str, Any]      )   ->				Optional[int]:


     '''simple docstring'''




     for n in graph_proto.node:
          _node_replace_input_with(snake_case_ ,   snake_case_ ,   snake_case_      )





def      lowerCAmelCase_    ( snake_case_	:			List[str] ,   snake_case_	:			Any ,   snake_case_	:			Optional[Any]      )   ->				Optional[int]:


     '''simple docstring'''




     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 ,   snake_case_ ,   snake_case_      )






def      lowerCAmelCase_    ( snake_case_	:			int      )   ->				Optional[Any]:


     '''simple docstring'''




     UpperCAmelCase_	   =       os.path.dirname(snake_case_      )
     UpperCAmelCase_	   =       os.path.basename(snake_case_      )

     UpperCAmelCase_	   =       onnx.load(os.path.join(snake_case_ ,   snake_case_      )      )

     UpperCAmelCase_	   =       list(model.graph.initializer      )

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

     UpperCAmelCase_	   =       0

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

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

                    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 == 11:
                         mem_size *= 8
                    else:
                         print("unexpected data type: " ,   snake_case_      )
                    total_reduced_size += mem_size

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

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

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

     UpperCAmelCase_	   =       sorted(snake_case_      )
     _remove_dup_initializers_from_model(snake_case_ ,   snake_case_ ,   snake_case_      )

     UpperCAmelCase_	   =       "optimized_" + model_file_name
     UpperCAmelCase_	   =       os.path.join(snake_case_ ,   snake_case_      )
     onnx.save(snake_case_ ,   snake_case_      )

     return new_model




