code: def test_reuse_of_env_thread_across_functions_is_ill_formed():
      """An env thread may not be reused across PrimFunc
  
      However, each function must have its own `tir.Var` representing
      the environment thread, and may not share these variables across
      PrimFuncs.
      """
  
      threadIdx_x = tvm.tir.Var("threadIdx_x", "int32")
  
      @I.ir_module
      class mod:
          @T.prim_func
          def kernel_1(A: T.Buffer([256], "float32")):
              T.attr(
                  T.iter_var(
                      threadIdx_x,
                      T.Range(0, 256),
                      "ThreadIndex",
                      "threadIdx.x",
                  ),
                  "thread_extent",
                  256,
              )
              A[threadIdx_x] = A[threadIdx_x] + T.float32(1)
  
          @T.prim_func
          def kernel_2(A: T.Buffer([256], "float32")):
              T.attr(
                  T.iter_var(
                      threadIdx_x,
                      T.Range(0, 256),
                      "ThreadIndex",
                      "threadIdx.x",
                  ),
                  "thread_extent",
                  256,
              )
              A[threadIdx_x] = A[threadIdx_x] + T.float32(1)
  
      with pytest.raises(
          ValueError,
          match="multiple definitions of variable threadIdx_x",
      ):
          tvm.tir.analysis.verify_well_formed(mod)
  
file_path: tvm/tests/python/tir-analysis/test_tir_analysis_verify_well_formed.py
imports: import pytest
  import tvm
  import tvm.testing
  from tvm.script import ir, tir
label_desc: Use image node_id 9 for calling a global function with example usage: test_reuse_of_env_thread_across_functions_is_ill_formed() without return types