code: def test_cond():
      # whether there are free variables in three graphs
      # whether these three graphs contain input_vars
      # whether to use all input_vars
      # which branch to choose
      def run_case(cond_func, then_func, else_func, **params):
          def make_cond(is_inverse):
              def cond(inputs, free):
                  x = cond_func(inputs, free)
                  if is_inverse:
                      if isinstance(x, mx.sym.Symbol):
                          return mx.sym.logical_not(x)
                      else:
                          return mx.nd.logical_not(x)
                  return x
  
              return cond
  
          for is_train in [True, False]:
              for is_inverse in [False, True]:
                  _verify_cond(
                      cond_func=make_cond(is_inverse),
                      then_func=then_func,
                      else_func=else_func,
                      is_train=is_train,
                      **params,
                  )
  
      # Each function can
      # 1. use_free_vars or not: T/F
      # 2. use_input_vars or not: T/F
      # 3. use_all_input_vars or not: T/F
      # (a, b, c) are inputs, (d, e, f) are free_vars
      cond_funcs = [
          lambda a, b, c, d, e, f: (a * b).sum() < 0.5,  # F, T, F
          lambda a, b, c, d, e, f: (a + b + c).sum() < 0.5,  # F, T, T
          lambda a, b, c, d, e, f: (d + e).sum() < 0.5,  # T, F, F
          lambda a, b, c, d, e, f: (d + e * a).sum() < 0.5,  # T, T, F
          lambda a, b, c, d, e, f: (d + e * a + b * c).sum()
          < 0.5,  # T, T, T
      ]
      body_funcs = [
          lambda a, b, c, d, e, f: a * b,  # F, T, F
          lambda a, b, c, d, e, f: a * b * c,  # F, T, T
          lambda a, b, c, d, e, f: d * e,  # T, F, F
          lambda a, b, c, d, e, f: d * e * a,  # T, T, F
          lambda a, b, c, d, e, f: d * e * a * b * c,  # T, T, T
          # some extra tests
          lambda a, b, c, d, e, f: b * c,
          lambda a, b, c, d, e, f: a * c,
          lambda a, b, c, d, e, f: (a + b) * c,
          lambda a, b, c, d, e, f: c * (b - a),
      ]
      # enumerate all kinds of possible combinations
      for cond_func in cond_funcs:
          for then_func in body_funcs:
              for else_func in body_funcs:
                  run_case(
                      cond_func=lambda x, y: cond_func(
                          x[0], x[1], x[2], y[0], y[1], y[2]
                      ),
                      then_func=lambda x, y: then_func(
                          x[0], x[1], x[2], y[0], y[1], y[2]
                      ),
                      else_func=lambda x, y: else_func(
                          x[0], x[1], x[2], y[0], y[1], y[2]
                      ),
                      input_var_shapes=[
                          (2, 3),
                          (2, 3),
                          (2, 3),
                      ],
                      free_var_shapes=[
                          (2, 3),
                          (2, 3),
                          (2, 3),
                      ],
                  )
  
file_path: mxnet/tests/python/unittest/test_contrib_control_flow.py
imports: import pytest
  import mxnet
  from numpy.testing import assert_allclose
  from mxnet.test_utils import *
  from mxnet.base import _as_list
label_desc: Use image node_id 5 for calling a global function with example usage: test_cond() and returns: cond, x, mx, mx