code: def _assert_dc(
      setup,
      compute,
      mode="all",
      setup_is_deterministic=True,
      numpy=True,
  ):
      """Compare results of deferred compute and normal imperative mode.
  
      Parameters
      ----------
      setup : callable
          Setup function computing inputs for compute function. Always called
          outside of deferred compute.
      compute : callable
          Compute function. We compare the output between normal computation and
          deferred compute.
      mode : {'all', 'symbolic', 'imperative', 'imperativewithnondccompute'}
          Compare deferred compute outputs triggered via imperative computation
          (eg. asnumpy() conversion) or obtained from the exported symbol or
          both.
      setup_is_deterministic : bool
          If True, setup function may be called multiple times. If False, will
          only be called once.
      numpy : bool
          If True, use mx.np. Otherwise mx.nd.
  
      """
      try:
          nd = mx.np if numpy else mx.nd
          if numpy:
              mx.npx.set_np()
  
          xs = setup(nd=nd)
          ys = compute(*xs, nd=nd)
  
          ys_np = [y.asnumpy() for y in ys]
  
          if setup_is_deterministic:
              xs = setup(nd=nd)
  
          xs_names = list(map(str, range(len(xs))))
          symbol_inputs = [
              mx.symbol.var(name).as_np_ndarray()
              if numpy
              else mx.symbol.var(name)
              for arg, name in zip(xs, xs_names)
          ]
          dc.set_variable(xs, symbol_inputs)
          with dc.context():
              ys_dc = compute(*xs, nd=nd)
  
          assert mode in (
              "all",
              "symbolic",
              "imperative",
              "imperativewithnondccompute",
          )
          if mode in ("all", "imperativewithnondccompute"):
              ys_dc_np = [(y + 0).asnumpy() for y in ys_dc]
              _all_same(ys_np, ys_dc_np)
  
          if mode in ("all", "imperative"):
              ys_dc_np = [y.asnumpy() for y in ys_dc]
              _all_same(ys_np, ys_dc_np)
  
          if mode in ("all", "symbolic"):
              sym = dc.get_symbol(
                  ys_dc,
                  sym_cls=mx.sym.np._Symbol if numpy else mx.sym.Symbol,
              )
  
              if setup_is_deterministic:
                  xs = setup(nd=nd)
  
              args = {name: x for name, x in zip(xs_names, xs)}
              ys_sym = sym._bind(
                  mx.device.current_device(), args=args
              ).forward()
  
              ys_sym_np = [y.asnumpy() for y in ys_sym]
              _all_same(ys_np, ys_sym_np)
      finally:
          if numpy:
              mx.npx.reset_np()
  
imports: import functools
  import operator
  import numpy
  import mxnet
  import mxnet._deferred_compute
  from mxnet.base import MXNetError
  from mxnet.util import TemporaryDirectory
  import pytest
label_desc: Use image node_id 2 for calling a global function with example usage: _assert_dc(setup, compute, mode, setup_is_deterministic, numpy) without return types