code: def test_dynamic_reshape(run_module):
      def test_run(
          x_data_list, x_shape, new_shape, should_offload_to_trt
      ):
          result_arr = [{} for _ in range(len(x_data_list))]
          for use_trt in [True, False]:
              x = relay.var("x", shape=x_shape, dtype="float32")
              out = relay.reshape(x, new_shape)
              f = relay.Function([x], out)
              mod = tvm.IRModule()
              mod["main"] = f
              if use_trt:
                  logging.info("Before partitioning:\n%s", mod)
                  mod = tensorrt.partition_for_tensorrt(mod)
                  logging.info("After partitioning:\n%s", mod)
                  assert (
                      are_ops_on_trt(mod, op_list=["reshape"])
                      == should_offload_to_trt
                  )
              if run_module:
                  with relay.build_config(opt_level=3):
                      func = relay.create_executor(
                          "vm",
                          mod=mod,
                          device=tvm.cpu(0),
                          target="llvm",
                      ).evaluate()
  
                  for i, x_data in enumerate(x_data_list):
                      result_arr[i][use_trt] = func(x_data)
  
          if run_module:
              for i in range(len(x_data_list)):
                  assert_result_dict_holds(result_arr[i])
  
      dim_values = [1, 1, 0, 2, 3, 0, 1, 3, 2]
      x_shape = (relay.Any(), 3, 2, 3)
      x_data_list = [
          np.ones([dim_value] + list(x_shape)[1:]).astype("float32")
          for dim_value in dim_values
      ]
      new_shape = (-1, 3, 2, 3)
      should_offload_to_trt = True
      test_run(x_data_list, x_shape, new_shape, should_offload_to_trt)
  
      dim_values = [1, 1, 0, 2, 3, 0, 1, 3, 2]
      x_shape = (relay.Any(), 3, 2, 3)
      x_data_list = [
          np.ones([dim_value] + list(x_shape)[1:]).astype("float32")
          for dim_value in dim_values
      ]
      new_shape = (-1, 1, 2, 3)
      should_offload_to_trt = False
      test_run(x_data_list, x_shape, new_shape, should_offload_to_trt)
  
      dim_values = [1, 1, 0, 2, 3, 0, 1, 3, 2]
      x_shape = (1, relay.Any(), 2, 3)
      x_data_list = [
          np.ones(
              list(x_shape[:1]) + [dim_value] + list(x_shape)[2:]
          ).astype("float32")
          for dim_value in dim_values
      ]
      new_shape = (1, -1, 2, 3)
      should_offload_to_trt = False
      test_run(x_data_list, x_shape, new_shape, should_offload_to_trt)
  
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 27 for calling a global function with example usage: test_dynamic_reshape(run_module) without return types