code: def unittest_helper(
      root_node,
      forward_input,
      expected_forward,
      expected_backward,
      device_id=-1,
      precision="float",
  ):
      assert isinstance(root_node, Function)
  
      backward_pass = expected_backward is not None
      forward, backward = cntk_eval(
          root_node,
          forward_input,
          precision,
          cntk_device(device_id),
          backward_pass,
          expected_backward,
      )
  
      # for forward we always expect only one result
      assert len(forward) == 1
      forward = list(forward.values())[0]
  
      forward = np.atleast_1d(forward)
  
      for res, exp in zip(forward, expected_forward):
          assert res.shape == AA(exp).shape
          assert np.allclose(res, exp, atol=TOLERANCE_ABSOLUTE)
  
      if expected_backward:
          for key in expected_backward:
              res, exp = backward[key], expected_backward[key]
              if isinstance(res, list):
                  assert len(res) == len(exp)
                  for res_seq, exp_seq in zip(res, exp):
                      assert res_seq.shape == AA(exp_seq).shape
                      assert np.allclose(
                          res_seq, exp_seq, atol=TOLERANCE_ABSOLUTE
                      )
  
              elif isinstance(res, np.ndarray):
                  assert res.shape == AA(exp).shape
                  assert np.allclose(res, exp, atol=TOLERANCE_ABSOLUTE)
  
file_path: CNTK/bindings/python/cntk/ops/tests/ops_test_utils.py
imports: import os
  import numpy
  import cntk
  from cntk.tests.test_utils import *
  from cntk.device import cpu, gpu
  from ...ops.functions import Function
  from cntk.internal import sanitize_dtype_cntk
  from cntk.internal.utils import eval
  from ..None import constant
label_desc: Use image node_id 6 for calling a global function with example usage: unittest_helper(root_node, forward_input, expected_forward, expected_backward, device_id, precision) without return types