




"""simple docstring"""


import argparse
import json
import os

from tensorflow.core.protobuf.saved_model_pba import SavedModel


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_copies.py
A_      			=       '''.'''

# Internal TensorFlow ops that can be safely ignored (mostly specific to a saved model)
A_      			=       [
    '''Assert''',
    '''AssignVariableOp''',
    '''EmptyTensorList''',
    '''MergeV2Checkpoints''',
    '''ReadVariableOp''',
    '''ResourceGather''',
    '''RestoreV2''',
    '''SaveV2''',
    '''ShardedFilename''',
    '''StatefulPartitionedCall''',
    '''StaticRegexFullMatch''',
    '''VarHandleOp''',
]


def       UpperCAmelCase__ (snake_case__							:      Union[str, Any]	,     snake_case__							:      int	,     snake_case__							:      Tuple					):
  """simple docstring"""

  _snake_case							:	Union[str, Any]			=						SavedModel()
  _snake_case							:	Optional[Any]			=						[]

  with open(os.path.join(snake_case__	,     """utils"""	,     """tf_ops"""	,     """onnx.json"""					)					) as f:
    _snake_case							:	Any			=						json.load(snake_case__					)["""opsets"""]

  for i in range(1	,     opset + 1					):
    onnx_ops.extend(onnx_opsets[str(snake_case__					)]					)

  with open(snake_case__	,     """rb"""					) as f:
    saved_model.ParseFromString(f.read()					)

  _snake_case							:	List[Any]			=						set()

  # Iterate over every metagraph in case there is more than one (a saved model can contain multiple graphs)
  for meta_graph in saved_model.meta_graphs:
    # Add operations in the graph definition
    model_op_names.update(node.op for node in meta_graph.graph_def.node					)

    # Go through the functions in the graph definition
    for func in meta_graph.graph_def.library.function:
      # Add operations in each function
      model_op_names.update(node.op for node in func.node_def					)

    # Convert to list, sorted if you want
  _snake_case							:	Tuple			=						sorted(snake_case__					)
  _snake_case							:	str			=						[]

  for op in model_op_names:
    if op not in onnx_ops and op not in INTERNAL_OPS:
      incompatible_ops.append(snake_case__					)

  if strict and len(snake_case__					) > 0:
    raise Exception(F"Found the following incompatible ops for the opset {opset}:\n" + incompatible_ops					)
  elif len(snake_case__					) > 0:
    print(F"Found the following incompatible ops for the opset {opset}:"					)
    print(*snake_case__	,     sep="""\n"""					)
  else:
    print(F"The saved model {saved_model_path} can properly be converted with ONNX."					)


if __name__ == "__main__":
     A_      			=       argparse.ArgumentParser()
     parser.add_argument('''--saved_model_path''', help='''Path of the saved model to check (the .pb file).''')
     parser.add_argument(
         '''--opset''', default=12, type=int, help='''The ONNX opset against which the model has to be tested.'''
     )
     parser.add_argument(
         '''--framework''', choices=['''onnx'''], default='''onnx''', help='''Frameworks against which to test the saved model.'''
     )
     parser.add_argument(
         '''--strict''', action='''store_true''', help='''Whether make the checking strict (raise errors) or not (raise warnings)'''
     )
     A_      			=       parser.parse_args()

     if args.framework == "onnx":
          onnx_compliancy(args.saved_model_path, args.strict, args.opset)












"""simple docstring"""


from __future__ import annotations

import math


def       UpperCAmelCase__ (snake_case__							:      int					):
  """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


A_      			=       [num for num in range(3, 10_00_01, 2) if not is_prime(num)]


def       UpperCAmelCase__ (snake_case__							:      int					):
  """simple docstring"""

  if not isinstance(snake_case__	,     snake_case__					):
    raise ValueError("""n must be an integer"""					)
  if n <= 0:
    raise ValueError("""n must be >= 0"""					)

  _snake_case							:	Any			=						[]
  for num in range(len(snake_case__					)					):
    _snake_case							:	Optional[int]			=						0
    while 2 * i * i <= odd_composites[num]:
      _snake_case							:	Optional[int]			=						odd_composites[num] - 2 * i * i
      if is_prime(snake_case__					):
        break
      i += 1
    else:
      list_nums.append(odd_composites[num]					)
      if len(snake_case__					) == n:
        return list_nums

  return []


def       UpperCAmelCase__ ():
  """simple docstring"""

  return compute_nums(1					)[0]


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


