code: def test_ref_create_read_write():
      target = "relu"
  
      @tvm.ir.register_op_attr("nn.relu", "target." + target)
      def annotate(expr):
          return True
  
      def before():
          ref = relay.expr.RefCreate(relay.const(1.0))
          r = relay.expr.RefWrite(
              ref, relay.nn.relu(relay.expr.RefRead(ref))
          )
          return tvm.IRModule.from_expr(r)
  
      def after(annotate_non_call_ops):
          co = relay.const(1.0)
          if annotate_non_call_ops:
              co = relay.annotation.compiler_begin(co, "default")
  
          ref = relay.expr.RefCreate(co)
          ref1 = ref
          if annotate_non_call_ops:
              ref = relay.annotation.compiler_end(ref, "default")
              ref = relay.annotation.compiler_begin(ref, "default")
              ref1 = relay.annotation.compiler_end(ref1, "default")
              ref1 = relay.annotation.compiler_begin(ref1, "default")
  
          read = relay.expr.RefRead(ref1)
          if annotate_non_call_ops:
              read = relay.annotation.compiler_end(read, "default")
  
          beg = relay.annotation.compiler_begin(read, target)
          relu = relay.nn.relu(beg)
          end = relay.annotation.compiler_end(relu, target)
  
          if annotate_non_call_ops:
              end = relay.annotation.compiler_begin(end, "default")
  
          r = relay.expr.RefWrite(ref, end)
  
          if annotate_non_call_ops:
              r = relay.annotation.compiler_end(r, "default")
          return tvm.IRModule.from_expr(r)
  
      for annotate_non_call_ops in [True, False, True]:
          result = transform.AnnotateTarget(
              target, annotate_non_call_ops
          )(before())
          expected = transform.InferType()(after(annotate_non_call_ops))
          assert tvm.ir.structural_equal(expected, result)
  
imports: import os
  import sys
  import numpy
  import pytest
  import tvm
  import tvm.relay.testing
  import tvm.relay.transform
  from tvm import relay
  from tvm import runtime
  from tvm.contrib import utils
label_desc: Use image node_id 6 for calling a global function with example usage: test_ref_create_read_write() and returns: True, tvm, tvm