code: def check_fused_symbol(sym, **kwargs):
      inputs = sym.list_inputs()
      shapes = {inp: kwargs[inp].shape for inp in inputs}
      ctx = kwargs.get("ctx", mx.gpu(0))
      # Double identity so that there is always something to fuse
      test_sym = mx.sym.Group(
          [mx.sym.identity(mx.sym.identity(s)) for s in sym]
      )
      rtol = {
          "float16": 1e-2,
          "float32": 1.5e-6,
          "float64": 1.5e-6,
      }
      atol = {
          "float16": 1e-3,
          "float32": 1e-7,
          "float64": 1e-7,
      }
      for dtype in ["float16", "float32", "float64"]:
          data = {inp: kwargs[inp].astype(dtype) for inp in inputs}
          for grad_req in ["write", "add"]:
              type_dict = {inp: dtype for inp in inputs}
              with environment("MXNET_USE_FUSION", "0"):
                  orig_exec = test_sym._simple_bind(
                      ctx=ctx,
                      grad_req=grad_req,
                      type_dict=type_dict,
                      **shapes,
                  )
              with environment("MXNET_USE_FUSION", "1"):
                  fused_exec = test_sym._simple_bind(
                      ctx=ctx,
                      grad_req=grad_req,
                      type_dict=type_dict,
                      **shapes,
                  )
              fwd_orig = orig_exec.forward(is_train=True, **data)
              out_grads = [mx.nd.ones_like(arr) for arr in fwd_orig]
              orig_exec.backward(out_grads=out_grads)
              fwd_fused = fused_exec.forward(is_train=True, **data)
              fused_exec.backward(out_grads=out_grads)
              for orig, fused in zip(fwd_orig, fwd_fused):
                  np.testing.assert_allclose(
                      orig.asnumpy(),
                      fused.asnumpy(),
                      rtol=rtol[dtype],
                      atol=atol[dtype],
                  )
              for orig, fused in zip(
                  orig_exec.grad_arrays, fused_exec.grad_arrays
              ):
                  if orig is None and fused is None:
                      continue
                  assert orig is not None
                  assert fused is not None
                  np.testing.assert_allclose(
                      orig.asnumpy(),
                      fused.asnumpy(),
                      rtol=rtol[dtype],
                      atol=atol[dtype],
                  )
  
file_path: mxnet/tests/python/gpu/test_fusion.py
imports: import sys
  import os
  import random
  import itertools
  import mxnet
  import numpy
  from mxnet import autograd, gluon
  from mxnet.test_utils import *
label_desc: Use image node_id 1 for calling a global function with example usage: check_fused_symbol(sym) without return types