code: def compile_tvm_graph_executor(
      model,
      model_name,
      layout,
      compute_layout,
      batch_size,
      seq_length,
      dtype,
      instance_type,
  ):
      key = (
          model_name,
          layout,
          compute_layout,
          batch_size,
          seq_length,
          dtype,
          instance_type,
      )
      if key in _TVM_RT_CACHE:
          return _TVM_RT_CACHE[key]
      tvm = try_import_tvm()
      from tvm import relay
      from tvm.contrib import graph_executor
      from gluonnlp.utils.tvm_utils import (
          get_ec2_tvm_flags,
          update_tvm_convert_map,
      )
  
      flags = get_ec2_tvm_flags()[instance_type]
      update_tvm_convert_map()
      token_ids_shape = (
          (batch_size, seq_length)
          if layout == "NT"
          else (seq_length, batch_size)
      )
      valid_length_shape = (batch_size,)
      if "bart" in model_name:
          shape_dict = {
              "data0": token_ids_shape,
              "data1": valid_length_shape,
              "data2": token_ids_shape,
              "data3": valid_length_shape,
          }
          dtype_dict = {
              "data0": "int32",
              "data1": "int32",
              "data2": "int32",
              "data3": "int32",
          }
      elif "roberta" in model_name or "xlmr" in model_name:
          shape_dict = {
              "data0": token_ids_shape,
              "data1": valid_length_shape,
          }
          dtype_dict = {
              "data0": "int32",
              "data1": "int32",
          }
      else:
          shape_dict = {
              "data0": token_ids_shape,
              "data1": token_ids_shape,
              "data2": valid_length_shape,
          }
          dtype_dict = {
              "data0": "int32",
              "data1": "int32",
              "data2": "int32",
          }
      sym = model._cached_graph[1]
      params = {}
      for k, v in model.collect_params().items():
          params[v._var_name] = tvm.nd.array(v.data().asnumpy())
      mod, params = relay.frontend.from_mxnet(
          sym, shape=shape_dict, dtype=dtype_dict, arg_params=params
      )
      target = flags["target"]
      use_gpu = flags["use_gpu"]
      opt_level = flags["opt_level"]
      required_pass = flags["required_pass"]
      with tvm.transform.PassContext(
          opt_level=opt_level, required_pass=required_pass
      ):
          lib = relay.build(mod, target, params=params)
      if use_gpu:
          ctx = tvm.gpu()
      else:
          ctx = tvm.cpu()
      rt = graph_executor.GraphModule(lib["default"](ctx))
      _TVM_RT_CACHE[key] = rt
      return rt
  
imports: import copy
  import csv
  import linecache
  import logging
  import os
  import platform
  import sys
  import timeit
  import numpy
  import gluonnlp
  from gluonnlp.models import get_backbone
  from gluonnlp.utils.misc import logging_config
  from gluonnlp.utils.lazy_imports import try_import_tvm
  from collections import defaultdict, namedtuple
  from datetime import datetime
  import multiprocessing
  from multiprocessing import Pipe, Process, Queue
  from multiprocessing.connection import Connection
  from typing import Callable, Iterable, List, NamedTuple, Optional, Union, Tuple
label_desc: Use image node_id 13 for calling a global function with example usage: compile_tvm_graph_executor(model, model_name, layout, compute_layout, batch_size, seq_length, dtype, instance_type) and returns: rt, _TVM_RT_CACHE