docstr: Run original and compiled model and compare the results.
  
  Args:
      model: The model to test.
      dynamo_backend: The dynamo backend to use. Here we use string `onnxrt` or
        the first returned value of `make_aot_ort(dynamic=True)`.
      example_args_collection: A tuple of example arguments to test. E.g.,
          (
            (torch.randn(2), torch.randn(2)),
            (torch.randn(4), torch.randn(4)),
          )
        if you want to test
          model(torch.randn(2), torch.randn(2)) and
          model(torch.randn(4), torch.randn(4))
        .
docstr_tok: ["Run","original","and","compiled","model","and","compare","the","results",".","Args",":","model",":","The","model","to","test",".","dynamo_backend",":","The","dynamo","backend","to","use",".","Here","we","use","string","`","onnxrt","`","or","the","first","returned","value","of","`","make_aot_ort","(","dynamic=True",")","`",".","example_args_collection",":","A","tuple","of","example","arguments","to","test",".","E.g.",",","(","(","torch.randn","(","2",")",",","torch.randn","(","2",")",")",",","(","torch.randn","(","4",")",",","torch.randn","(","4",")",")",",",")","if","you","want","to","test","model","(","torch.randn","(","2",")",",","torch.randn","(","2",")",")","and","model","(","torch.randn","(","4",")",",","torch.randn","(","4",")",")","."]
code: def _test_model_numerically(
      self,
      model,
      dynamo_backend,
      example_args_collection,
      fullgraph: bool = False,
      test_backward: bool = False,
      atol: float = 1e-5,
      rtol: float = 1e-6,
  ):
      """Run original and compiled model and compare the results.
  
      Args:
          model: The model to test.
          dynamo_backend: The dynamo backend to use. Here we use string `onnxrt` or
            the first returned value of `make_aot_ort(dynamic=True)`.
          example_args_collection: A tuple of example arguments to test. E.g.,
              (
                (torch.randn(2), torch.randn(2)),
                (torch.randn(4), torch.randn(4)),
              )
            if you want to test
              model(torch.randn(2), torch.randn(2)) and
              model(torch.randn(4), torch.randn(4))
            .
      """
      compiled_model = torch.compile(
          model
          if not isinstance(model, torch.nn.Module)
          else copy.deepcopy(model),
          backend=dynamo_backend,
          dynamic=True,
          fullgraph=fullgraph,
      )
  
      for example_args in example_args_collection:
          baseline_result = model(*example_args)
          result = compiled_model(*example_args)
          if isinstance(baseline_result, torch.Tensor):
              torch.testing.assert_close(
                  baseline_result, result, atol=atol, rtol=rtol
              )
              if test_backward:
                  baseline_result.sum().backward()
                  result.sum().backward()
                  for baseline_param, param in zip(
                      model.parameters(), compiled_model.parameters()
                  ):
                      torch.testing.assert_close(
                          baseline_param.grad,
                          param.grad,
                          atol=atol,
                          rtol=rtol,
                      )
          else:
              assert (
                  test_backward is False
              ), "Calculating backward with multiple outputs is not supported yet."
              for baseline_elem, result_elem in zip(
                  baseline_result, result
              ):
                  torch.testing.assert_close(
                      baseline_elem, result_elem, atol=atol, rtol=rtol
                  )
  
imports: from __future__ import annotations
  import copy
  import dataclasses
  import os
  import sys
  from typing import Tuple
  import onnxruntime
  import torch
  import torch._dynamo.backends.registry
  from parameterized import parameterized
  from torch import nn
  from torch.onnx import _OrtBackend, _OrtBackendOptions, ExportOptions
  from torch.testing._internal import common_utils
  import onnx_test_common
label_desc: Use image node_id 7 for calling the TestDynamoWithONNXRuntime obj's underlying member method code with example usage: obj._test_model_numerically(model, dynamo_backend, example_args_collection, fullgraph, test_backward, atol, rtol) without return types