code: def test_uniq_name():
      class ForeachLayer1(gluon.HybridBlock):
          def __init__(self):
              super(ForeachLayer1, self).__init__()
  
          def forward(self, inputs, states):
              def step1(data, states):
                  return data + 1, states
  
              out1, states1 = mx.npx.foreach(step1, inputs, states)
              # The input variables have the same symbol name.
              out, states = mx.npx.foreach(step1, out1, states1)
              return out
  
      class ForeachLayer2(gluon.HybridBlock):
          def __init__(self):
              super(ForeachLayer2, self).__init__()
  
          def forward(self, inputs, states):
              def step1(data, states):
                  return data + 1, states
  
              out1, states1 = mx.npx.foreach(step1, inputs, states)
  
              def step2(data, states):
                  return data, [
                      states[0]
                      + states[0]
                      + mx.np.squeeze(
                          mx.npx.slice(data, begin=0, end=1)
                      )
                  ]
  
              # The input variables have the same symbol names.
              # The free variables have the same symbol names as the input variables.
              out, states = mx.npx.foreach(step2, out1, states1)
              return out
  
      class WhileLayer1(gluon.HybridBlock):
          def __init__(self):
              super(WhileLayer1, self).__init__()
  
          def forward(self, inputs, states):
              def cond(state1, state2):
                  s = mx.np.squeeze(
                      mx.npx.slice(state1, begin=0, end=1)
                  )
                  return s == s
  
              def step(state1, state2):
                  return state1 + 1, [state1 + 1, state2 + 1]
  
              states = [states[0], states[0] + 1]
              out1, states1 = mx.npx.while_loop(
                  cond, step, states, max_iterations=5
              )
              # The input variables have the same symbol name.
              out, states = mx.npx.while_loop(
                  cond, step, states1, max_iterations=5
              )
              return out
  
      class WhileLayer2(gluon.HybridBlock):
          def __init__(self):
              super(WhileLayer2, self).__init__()
  
          def forward(self, inputs, states):
              def cond(state1, state2):
                  s = mx.np.squeeze(
                      mx.npx.slice(state1, begin=0, end=1)
                  )
                  return s == s
  
              def step1(state1, state2):
                  return state1 + 1, [state1, state2]
  
              states = [states[0], states[0] + 1]
              out1, states1 = mx.npx.while_loop(
                  cond, step1, states, max_iterations=5
              )
  
              def step2(state1, state2):
                  return state1 + 1, [
                      state1 + state1[0],
                      state2 + state1[1],
                  ]
  
              # The input variables have the same symbol name.
              out, states = mx.npx.while_loop(
                  cond, step2, states1, max_iterations=5
              )
              return out
  
      TestLayers = [
          ForeachLayer1,
          ForeachLayer2,
          WhileLayer1,
          WhileLayer2,
      ]
      # TestLayers = [WhileLayer1]
  
      data = mx.np.random.normal(loc=0, scale=1, size=(2, 5))
      states = mx.np.random.normal(loc=0, scale=1, size=(5))
      for TestLayer in TestLayers:
          layer = TestLayer()
          layer.initialize(device=default_device())
          res1 = layer(data, [states])
  
          with mx.autograd.record():
              res1 = layer(data, [states])
  
          layer = TestLayer()
          layer.initialize(device=default_device())
          layer.hybridize()
          res2 = layer(data, [states])
  
          with mx.autograd.record():
              res2 = layer(data, [states])
          assert_almost_equal(
              res1.asnumpy(), res2.asnumpy(), rtol=0.001, atol=0.0001
          )
  
imports: import copy
  import numpy
  import mxnet
  from mxnet import gluon
  from mxnet.test_utils import *
  from mxnet.base import _as_list
  from collections import defaultdict
  from mxnet.attribute import AttrScope
label_desc: Use image node_id 3 for calling a global function with example usage: test_uniq_name() and returns: out, out, out, out, unknown,  states, unknown,  states, data,  list, unknown, unknown,  list, unknown, unknown,  list, unknown,  list