code: def test_multiple_use_of_an_output():
      def expected_same_output_region():
          mod = tvm.IRModule()
          x = relay.var("x", shape=(8, 8))
          y = relay.var("y", shape=(8, 8))
          z = relay.var("z", shape=(8, 8))
          x0 = relay.var("x0", shape=(8, 8))
          y0 = relay.var("y0", shape=(8, 8))
          log = relay.log(x0)
          sub = x0 - y0
          mul = log * sub
          # The partitioned graph contains log, subtract, and multiply
          func = relay.Function([x0, y0], mul)
          func = set_func_attr(
              func, "ccompiler", "tvmgen_default_ccompiler_main_0"
          )
          glb_0 = relay.GlobalVar("tvmgen_default_ccompiler_main_0")
          mod[glb_0] = func
          mod = transform.InferType()(mod)
  
          add = x + y
          call = relay.Call(glb_0, [add, z])
          main = relay.Function([x, y, z], call)
          mod["main"] = main
          mod = transform.InferType()(mod)
          return mod
  
      def expected_different_output_region():
          mod = tvm.IRModule()
          x = relay.var("x", shape=(8, 8))
          y = relay.var("y", shape=(8, 8))
          z = relay.var("z", shape=(8, 8))
  
          # The partitioned graph contains log
          i0 = relay.var("i0", shape=(8, 8))
          log = relay.log(i0)
          func = relay.Function([i0], log)
          func = set_func_attr(
              func, "ccompiler", "tvmgen_default_ccompiler_main_0"
          )
          glb_0 = relay.GlobalVar("tvmgen_default_ccompiler_main_0")
          mod[glb_0] = func
          mod = transform.InferType()(mod)
  
          # The partitioned graph contains subtract
          x0 = relay.var("x0", shape=(8, 8))
          y0 = relay.var("y0", shape=(8, 8))
          sub = x0 - y0
          func = relay.Function([x0, y0], sub)
          func = set_func_attr(
              func, "ccompiler", "tvmgen_default_ccompiler_main_1"
          )
          glb_1 = relay.GlobalVar("tvmgen_default_ccompiler_main_1")
          mod[glb_1] = func
          mod = transform.InferType()(mod)
  
          add = x + y
          call_log = relay.Call(glb_0, [add])
          call_sub = relay.Call(glb_1, [add, z])
          main = relay.Function([x, y, z], call_log * call_sub)
          mod["main"] = main
          mod = transform.InferType()(mod)
          return mod
  
      def get_mod():
          x = relay.var("x", shape=(8, 8))
          y = relay.var("y", shape=(8, 8))
          z = relay.var("z", shape=(8, 8))
          add = x + y
          sub = add - z
          log = relay.log(add)
          sub1 = log * sub
          f = relay.Function([x, y, z], sub1)
          mod = tvm.IRModule()
          mod["main"] = f
          return mod
  
      def test_same_output_region():
          mod = get_mod()
          mod = AllowedListAnnotator(
              ["subtract", "log", "multiply"], "ccompiler"
          )(mod)
          mod = transform.MergeCompilerRegions()(mod)
          mod = transform.PartitionGraph()(mod)
  
          expected_mod = expected_same_output_region()
          assert tvm.ir.structural_equal(
              mod, expected_mod, map_free_vars=True
          )
  
      def test_different_output_region():
          mod = get_mod()
          mod = AllowedListAnnotator(["subtract", "log"], "ccompiler")(
              mod
          )
          mod = transform.MergeCompilerRegions()(mod)
          mod = transform.PartitionGraph()(mod)
  
          expected_mod = expected_different_output_region()
          assert tvm.ir.structural_equal(
              mod, expected_mod, map_free_vars=True
          )
  
      test_same_output_region()
      test_different_output_region()
  
imports: import os
  import sys
  import numpy
  import tvm
  from tvm.relay.backend import te_compiler
  from tvm.relay.backend.runtime import Runtime
  import tvm.relay.testing
  import tvm.relay.op
  from tvm import relay
  from tvm import runtime
  from tvm.relay import transform
  from tvm.relay.testing import byoc
  from tvm.contrib import utils
  from tvm.relay.expr_functor import ExprMutator
  from tvm.relay.op.annotation import compiler_begin, compiler_end
  from tvm.relay.op.contrib.register import get_pattern_table
  from tvm.relay.build_module import bind_params_by_name
label_desc: Use image node_id 17 for calling a global function with example usage: test_multiple_use_of_an_output() and returns: mod, mod, mod