code: def prune_dnnl_subgraphs(mod):
      """
      Removes invalid subgraphs, which does not contain compute intensive dnnl ops.
      """
  
      class SubgraphRemover(ExprMutator):
          """
          Reverts subgraphs in subgraphs_to_remove back to TVM instead of using an external codegen.
          """
  
          def __init__(self, subgraphs_to_remove, mod, new_mod):
              ExprMutator.__init__(self)
              self.subgraphs_to_remove = subgraphs_to_remove
              self.mod = mod
              self.new_mod = new_mod
  
          def visit_call(self, call):
              if isinstance(call.op, GlobalVar):
                  name = call.op.name_hint
                  if name in self.subgraphs_to_remove:
                      # "Inline" the subgraph back into new main function.
                      func = self.mod[name]
                      var_map = {}
                      for arg, param in zip(call.args, func.params):
                          var_map[param] = super().visit(arg)
                      new_body = relay.bind(func.body, var_map)
                      return new_body
                  if name != "main":
                      args = []
                      for arg in call.args:
                          args.append(super().visit(arg))
                      return call.op(*args)
              return super().visit_call(call)
  
      subgraphs_to_remove = []
      # If only one subgraph, do nothing.
      if len(mod.get_global_vars()) <= 2:
          return mod
      # Remove invalid subgraphs
      for subgraph in mod.get_global_vars():
          name = subgraph.name_hint
          if (
              not mod[name].attrs
              or mod[name].attrs["Compiler"] != "dnnl"
          ):
              continue
          if not is_valid_subgraph(mod[name].body):
              subgraphs_to_remove.append(name)
      # Create new pruned module
      new_mod = tvm.IRModule(mod.functions, mod.type_definitions)
      new_mod["main"] = SubgraphRemover(
          subgraphs_to_remove, mod, new_mod
      ).visit(mod["main"])
      new_mod = transform.RemoveUnusedFunctions()(new_mod)
      return new_mod
  
imports: import logging
  from functools import reduce
  import tvm.ir
  from tvm import relay
  from tvm.ir import Op
  from tvm.relay import expr
  from tvm.relay import transform
  from tvm.relay.analysis import analysis
  from tvm.relay.expr import Call, GlobalVar, TupleGetItem, const
  from tvm.relay.expr_functor import ExprMutator, ExprVisitor
  from ...None import _ffi_api
  from ...dataflow_pattern import DFPatternCallback, is_constant, is_expr, is_op, rewrite, wildcard
  from .register import register_pattern_table
label_desc: Use image node_id 27 for calling a global function with example usage: prune_dnnl_subgraphs(mod) and returns: new_mod, mod, super, new_body, call