code: def check_fusion(
      net_original,
      data_shapes,
      attrs_dict,
      input_type="float32",
      check_fusion=True,
      check_quantization=True,
      out_types=["uint8", "int8", "auto"],
      dedup_subgraph=True,
      quantize_mode="full",
  ):
      net_original.initialize()
      net_original.hybridize(static_alloc=False, static_shape=False)
      one_shape = isinstance(data_shapes, tuple)
      data_min = -1.0 if input_type == "float32" else -10
      data_max = 1.0 if input_type == "float32" else 10
  
      if one_shape:
          # replace one shape with list of shapes with one element to follow later the same schema
          data_shapes = [data_shapes]
      data = []
      for shape in data_shapes:
          data.append(
              mx.np.random.uniform(
                  size=shape,
                  dtype=input_type,
                  device=mx.cpu(),
                  low=data_min,
                  high=data_max,
              )
          )
      net_original(*data)
      net_fusion = copy.copy(net_original)
      sym, _ = net_original.export(None)
  
      if check_fusion:
          if (
              "".join(sym.get_internals().list_outputs()).find("sqrt")
              != -1
          ):
              check_quantization = False
              data_min = 0
  
          sym_sg = sym.optimize_for(
              SG_PASS_NAME,
              dedup_subgraph=dedup_subgraph,
              skip_infer=True,
          )
          check_fusion_parameter(sym_sg, attrs_dict)
          if data_min == 0 and mx.npx.is_np_default_dtype():
              # regenerate inputs if they have different range or data type
              data = []
              for shape in data_shapes:
                  data.append(
                      mx.np.random.uniform(
                          size=shape,
                          device=mx.cpu(),
                          low=data_min,
                          high=data_max,
                      )
                  )
          out_unfused = net_original(*data)
  
          net_fusion.optimize_for(*data, backend=SG_PASS_NAME)
          out_fused = net_fusion(*data)
  
          assert_almost_equal(
              out_unfused.asnumpy(),
              out_fused.asnumpy(),
              rtol=1e-3,
              atol=1e-1,
          )
  
      if check_quantization:
          # fp32 to int8
          for out_type in out_types:
              check_quantize(
                  net_original,
                  data_shapes,
                  out_type,
                  name=list(attrs_dict.keys())[0],
                  quantize_mode=quantize_mode,
                  attrs_dict=attrs_dict,
              )
  
imports: import mxnet
  import numpy
  import unittest
  import pytest
  import ctypes
  import copy
  from mxnet.contrib import quantization
  from mxnet.gluon import nn
  from mxnet.test_utils import assert_almost_equal, assert_almost_equal_with_err
label_desc: Use image node_id 5 for calling a global function with example usage: check_fusion(net_original, data_shapes, attrs_dict, input_type, check_fusion, check_quantization, out_types, dedup_subgraph, quantize_mode) without return types