code: def validate_onnx_model(
      platform,
      device_type,
      model_file,
      input_file,
      mace_out_file,
      input_names,
      input_shapes,
      input_data_formats,
      output_names,
      output_shapes,
      output_data_formats,
      validation_threshold,
      input_data_types,
      output_data_types,
      backend,
      log_file,
  ):
      print("validate on onnxruntime.")
      import onnx
      import onnxruntime as onnxrt
  
      if not os.path.isfile(model_file):
          common.MaceLogger.error(
              VALIDATION_MODULE,
              "Input graph file '" + model_file + "' does not exist!",
          )
  
      model = onnx.load(model_file)
      remove_initializer_from_input(model)
      model_outputs = set()
      for output in model.graph.output:
          model_outputs.add(output.name)
      for output_name in output_names:
          if output_name not in model_outputs:
              layer_value_info = onnx.helper.ValueInfoProto()
              layer_value_info.name = output_name
              model.graph.output.append(layer_value_info)
  
      input_dict = {}
      for i in range(len(input_names)):
          input_value = load_data(
              common.formatted_file_name(input_file, input_names[i]),
              input_data_types[i],
          )
          input_value = input_value.reshape(input_shapes[i])
          if (
              input_data_formats[i] == common.DataFormat.NHWC
              and len(input_shapes[i]) == 4
          ):
              input_value = input_value.transpose((0, 3, 1, 2))
          input_dict[input_names[i]] = input_value
  
      sess = onnxrt.InferenceSession(model.SerializeToString())
      output_values = sess.run(output_names, input_dict)
  
      for i in range(len(output_names)):
          value = output_values[i].flatten()
          output_file_name = common.formatted_file_name(
              mace_out_file, output_names[i]
          )
          mace_out_value = load_data(
              output_file_name, output_data_types[i]
          )
          (
              mace_out_value,
              real_output_shape,
              real_output_data_format,
          ) = get_real_out_value_shape_df(
              platform,
              mace_out_value,
              output_shapes[i],
              output_data_formats[i],
          )
          compare_output(
              platform,
              device_type,
              output_names[i],
              mace_out_value,
              value,
              validation_threshold,
              log_file,
              real_output_shape,
              real_output_data_format,
          )
  
imports: import argparse
  import sys
  import os
  import os.path
  import numpy
  import six
  import common
label_desc: Use image node_id 13 for calling a global function with example usage: validate_onnx_model(platform, device_type, model_file, input_file, mace_out_file, input_names, input_shapes, input_data_formats, output_names, output_shapes, output_data_formats, validation_threshold, input_data_types, output_data_types, backend, log_file) without return types