code: def test_fanout():
      @script
      def fanout(n, a):
          three = 3.0
          b = output_tensor((a.shape[0] - 3,), a.dtype)
          for i in range(a.shape[0] - 3):
              sigma = 0.0
              for j in range(3):
                  sigma += a[i + j]
              sigma = sigma / three
              b[i] = sigma
          return b
  
      n = te.size_var("n")
      a = te.placeholder((n,), "float32", name="a")
      try:
          b = fanout(n, a)
          ir = b.op.body
      except IOError as err:
          assert (
              sys.version_info[0] == 2
              and str(err) == "could not get source code"
          )
          return
  
      # Check for i in (0, n-3)
      assert isinstance(ir, tvm.tir.For)
      assert ir.loop_var.name == "i"
      assert ir.min.value == 0
      assert tvm.ir.structural_equal(ir.extent, n - 3)
      # Check loopbody
      abody = ir.body
      assert isinstance(abody, tvm.tir.ProducerRealize)
      assert abody.bounds[0].min.value == 0
      assert abody.bounds[0].extent.value == 1
      assert abody.producer.op.name == "sigma"
      # Check i loop body
      rbody = abody.body
      assert isinstance(rbody[0], tvm.tir.ProducerStore)
      assert rbody[0].producer.op.name == "sigma"
      assert len(rbody[0].indices) == 1
      assert rbody[0].indices[0].value == 0
      # Check fanout loop
      jloop = rbody[1]
      assert jloop.loop_var.name == "j"
      assert jloop.min.value == 0
      assert jloop.extent.value == 3
      jbody = jloop.body
      assert isinstance(jbody, tvm.tir.ProducerStore)
      assert len(jbody.indices) == 1
      assert jbody.indices[0].value == 0
      assert jbody.producer.op.name == "sigma"
      assert isinstance(jbody.value, tvm.tir.Add)
      value = jbody.value
      assert isinstance(value.a, tvm.tir.ProducerLoad)
      assert value.a.producer.name == "sigma"
      assert len(value.a.indices) == 1
      assert value.a.indices[0].value == 0
      assert value.b.producer.name == "a"
      assert len(value.b.indices) == 1
      assert tvm.ir.structural_equal(
          value.b.indices[0], ir.loop_var + jloop.loop_var
      )
      divide = rbody[2]
      assert isinstance(divide, tvm.tir.ProducerStore)
      assert len(divide.indices) == 1
      assert divide.indices[0].value == 0
      value = divide.value
      assert isinstance(value, tvm.tir.Mul)
      assert value.a.producer.name == "sigma"
      assert len(value.a.indices) == 1
      assert value.a.indices[0].value == 0
      assert abs(value.b.value - (1 / 3.0)) < 1e-5
      write = rbody[3]
      assert isinstance(write, tvm.tir.ProducerStore)
      assert write.producer.op.name == "b"
      assert write.value.producer.name == "sigma"
      assert len(write.value.indices) == 1
      assert write.value.indices[0].value == 0
  
      func, ins, outs = run_and_check(fanout, [n, a], {n: 10})
      run_and_check(func, ins, {n: 10}, outs=outs)
  
imports: import tvm, inspect, sys, traceback, numpy, pytest, types, os
  from tvm import te
  from tvm.contrib import utils
  from tvm.te.hybrid import script
  from tvm.te.hybrid.runtime import HYBRID_GLOBALS
  import tvm.testing
label_desc: Use image node_id 4 for calling a global function with example usage: test_fanout() and returns: b