code: def test_onnx_model(model_name, round_trip):
      if model_name in skip_model_names and not round_trip:
          pytest.skip("Skip onnx model test. ")
      if model_name in skip_round_trip_model_names and round_trip:
          pytest.skip("Skip onnx model round trip test. ")
  
      model_dir = os.path.join(onnx_base_dir, model_name)
      model = C.Function.load(
          os.path.join(model_dir, "model.onnx"),
          format=C.ModelFormat.ONNX,
      )
  
      if round_trip:
          resave_model_path = "model_resave.onnx"
          model.save(resave_model_path, format=C.ModelFormat.ONNX)
          model = C.Function.load(
              resave_model_path, format=C.ModelFormat.ONNX
          )
  
      data_dirs = [
          os.path.join(model_dir, dir)
          for dir in os.listdir(model_dir)
          if os.path.isdir(os.path.join(model_dir, dir))
      ]
      for data_dir in data_dirs:
          inputs = []
          ref_outputs = []
          tensor = onnx.TensorProto()
  
          input_filenames = [
              filename
              for filename in os.listdir(data_dir)
              if input_filename_pattern.match(filename)
          ]
          input_files_sorted = [
              os.path.join(data_dir, "input_{:d}.pb".format(i))
              for i in range(len(input_filenames))
          ]
          output_filenames = [
              filename
              for filename in os.listdir(data_dir)
              if output_filename_pattern.match(filename)
          ]
          output_files_sorted = [
              os.path.join(data_dir, "output_{:d}.pb".format(i))
              for i in range(len(output_filenames))
          ]
  
          for input_file in input_files_sorted:
              with open(input_file, "rb") as f:
                  tensor.ParseFromString(f.read())
              inputs.append(numpy_helper.to_array(tensor))
  
          for output_file in output_files_sorted:
              with open(output_file, "rb") as f:
                  tensor.ParseFromString(f.read())
              ref_outputs.append(numpy_helper.to_array(tensor))
  
          cntk_input = {
              model.arguments[i]: inputs[i] for i in range(len(inputs))
          }
          cntk_res = [model.eval(cntk_input)]
  
          if ref_outputs[0].dtype == np.bool:
              cntk_res = [cntk_res[0].astype("bool")]
  
          outputs = list(cntk_res)
  
          np.testing.assert_equal(len(ref_outputs), len(outputs))
          for i in range(len(outputs)):
              np.testing.assert_equal(
                  ref_outputs[i].dtype, outputs[i].dtype
              )
              np.testing.assert_allclose(
                  ref_outputs[i], outputs[i], rtol=1e-3, atol=1e-4
              )
  
file_path: CNTK/bindings/python/cntk/tests/onnx_model_test.py
imports: import cntk
  import numpy
  import pytest
  import os
  import re
  import shutil
  import time
  import tempfile
  from onnx import numpy_helper
  from .onnx_verify_helper import generate_sequence_data, generate_sequential_data, generate_sparse_data, verify_results_with_onnxruntime, generate_sparse_data_non_seq
  from .onnx_test_helper import find_onnx_value_info_proto_with_matching_name, save_cntk_data_as_onnx_tensor, save_test_data, save_onnx_model_with_validation_data
  from .onnx_op_test import verify_sequence_model
label_desc: Use image node_id 2 for calling a global function with example usage: test_onnx_model(model_name, round_trip) without return types