code: def test_inplace_rule2(
      scope_tb="local_TB2", max_bits=1024 * 1024 * 1024
  ):
      # Test Buffer
      register_mem(scope_tb, max_bits)
      m = 10
      A = te.placeholder((m,), name="A")
      C = te.placeholder((m,), name="C")
      D = te.placeholder((m,), name="D")
      A0 = te.compute((m,), lambda i: A[i] + C[i], name="A0")
      A1 = te.compute((m,), lambda i: D[i] * D[i], name="A1")
      A2 = te.compute((m,), lambda i: A0[i] + A1[i], name="A2")
      B = te.compute((m,), lambda i: A2[i], name="B")
      s = te.create_schedule(B.op)
      A0L = s.cache_read(A0, scope_tb, [A2])
      A1L = s.cache_read(A1, scope_tb, [A2])
      A2L = s.cache_read(A2, scope_tb, [B])
      mod = schedule_to_module(s, [A, B, C, D])
      mod = tvm.tir.transform.StorageFlatten(64)(mod)
  
      mod = tvm.tir.transform.Simplify()(mod)
      mod = tvm.tir.transform.StorageRewrite()(mod)
      stmt = mod["main"].body
  
      # verify only have one allocations.
      # verify inplace folding works
      num_alloc = [0]
  
      def verify(n):
          if isinstance(n, tvm.tir.Allocate):
              num_alloc[0] += 1
  
      tvm.tir.stmt_functor.post_order_visit(stmt, verify)
      assert num_alloc[0] == 2
  
imports: import sys
  import pytest
  import tvm
  import tvm.testing
  from tvm import te
  from tvm.driver.build_module import schedule_to_module
  from tvm.script import tir
label_desc: Use image node_id 12 for calling a global function with example usage: test_inplace_rule2(scope_tb, max_bits) without return types