code: def test_dynamic_offload():
      """
      This test checks for proper dynamic offloading of relay graphs. An addition between
      the outputs of two conv2d's is performed, one of them having all static args whereas
      the other has a arg with dynamic shape. It is expected for the TRT partitioner to
      offload the conv2d with dynamic arg to TVM while running the other in TRT.
      """
  
      data_shape = (1, 32, 8, 8)
      k_shape = (1, 32, 3, 3)
  
      x = relay.var(
          "x",
          shape=(data_shape[0], data_shape[1], Any(), Any()),
          dtype="float32",
      )
      y = relay.var("y", shape=(data_shape), dtype="float32")
      kernel = relay.const(np.random.rand(*k_shape).astype("float32"))
  
      def get_expected():
          # Create a nested TRT function that matches the expected output
          mod = tvm.IRModule()
          outer_var = relay.var(
              "tensorrt_0_i0", shape=(data_shape), dtype="float32"
          )
          inner_var = relay.var(
              "FunctionVar_0_0", shape=(data_shape), dtype="float32"
          )
          inner_body = relay.nn.conv2d(
              inner_var,
              kernel,
              channels=k_shape[0],
              kernel_size=k_shape[2:4],
          )
          inner_func = relay.Function([inner_var], inner_body)
          inner_func = set_inner_func_attr(
              inner_func, "nn.conv2d_", "tensorrt.nn.conv2d"
          )
          outer_body = inner_func(outer_var)
          outer_func = relay.Function([outer_var], outer_body)
          outer_func = set_outer_func_attr(
              outer_func, "tensorrt", "tvmgen_default_tensorrt_main_0"
          )
          gv = GlobalVar("tvmgen_default_tensorrt_main_0")
          mod[gv] = outer_func
          mod = relay.transform.InferType()(mod)
  
          # Create the main function
          out1 = relay.nn.conv2d(
              x, kernel, channels=k_shape[0], kernel_size=k_shape[2:4]
          )
          out = relay.add(out1, gv(y))
          f = relay.Function([x, y], out)
          mod["main"] = f
          mod = relay.transform.InferType()(mod)
          return mod
  
      # Create relay function that will be offloaded to TRT
      out1 = relay.nn.conv2d(
          x, kernel, channels=k_shape[0], kernel_size=k_shape[2:4]
      )
      out2 = relay.nn.conv2d(
          y, kernel, channels=k_shape[0], kernel_size=k_shape[2:4]
      )
      out = relay.add(out1, out2)
      f = relay.Function([x, y], out)
  
      # Pass the function to TRT compilation
      mod = tvm.IRModule()
      mod["main"] = f
      mod = relay.transform.InferType()(mod)
      mod_trt = tensorrt.partition_for_tensorrt(mod)
  
      # Get the expected relay graph and compare
      mod_exp = get_expected()
      tvm.ir.assert_structural_equal(
          mod_trt, mod_exp, map_free_vars=True
      )
  
imports: import itertools
  import logging
  from typing import Tuple
  import numpy
  import pytest
  import tvm
  import tvm.relay.testing
  import tvm.testing
  from tvm import relay
  from tvm.contrib.download import download
  from tvm.relay import Any, GlobalVar
  from tvm.relay.expr_functor import ExprVisitor
  from tvm.relay.op.contrib import tensorrt
label_desc: Use image node_id 48 for calling a global function with example usage: test_dynamic_offload() and returns: mod