code: def run_ort_and_compare(
      sess, ort_input, output_example, check_tolerance=0.01
  ):
      # Verify the model can be read, and is valid
      ort_out = sess.run(None, ort_input)
      all_good = True
      for i, out in enumerate(ort_out):
          expected = output_example[i]
  
          if torch.is_tensor(expected):
              tout = torch.from_numpy(out)
              logging.debug(
                  f"Checking output {i}, shape: {expected.shape}:\n"
              )
              this_good = True
              try:
                  if not torch.allclose(
                      tout,
                      expected.cpu(),
                      rtol=check_tolerance,
                      atol=100 * check_tolerance,
                  ):
                      this_good = False
              except (
                  Exception
              ):  # there may ne size mismatch and it may be OK
                  this_good = False
              if not this_good:
                  logging.info(
                      f"onnxruntime results mismatch! PyTorch(expected):\n{expected}\nONNXruntime:\n{tout}"
                  )
                  all_good = False
      return all_good
  
imports: import os
  from contextlib import nullcontext
  from enum import Enum
  from typing import Callable, Dict, Optional, Type
  import onnx
  import torch
  import torch.nn
  import torch.nn.functional
  from nemo.utils import CastToFloat, CastToFloatAll, logging
label_desc: Use image node_id 10 for calling a global function with example usage: run_ort_and_compare(sess, ort_input, output_example, check_tolerance) and returns: all_good