code: def _check_batchnorm_result(input, num_devices=1, cuda=False):
      from mxnet.gluon.utils import split_and_load
  
      def _find_bn(module):
          if isinstance(
              module, (mx.gluon.nn.BatchNorm, mx.gluon.nn.SyncBatchNorm)
          ):
              return module
          elif isinstance(
              module.module,
              (mx.gluon.nn.BatchNorm, mx.gluon.nn.SyncBatchNorm),
          ):
              return module.module
  
          raise RuntimeError("BN not found")
  
      def _syncParameters(bn1, bn2, device):
          device = input.context
          bn2.gamma.set_data(bn1.gamma.data(device))
          bn2.beta.set_data(bn1.beta.data(device))
          bn2.running_mean.set_data(bn1.running_mean.data(device))
          bn2.running_var.set_data(bn1.running_var.data(device))
  
      input1 = input.copy()
      input2 = input.copy()
  
      if cuda:
          input1 = input.to_device(mx.gpu(0))
          device_list = [mx.gpu(i) for i in range(num_devices)]
      else:
          device_list = [mx.cpu(0) for _ in range(num_devices)]
  
      nch = input.shape[1]
      bn1 = mx.gluon.nn.BatchNorm(in_channels=nch)
      bn2 = mx.gluon.nn.SyncBatchNorm(
          in_channels=nch, num_devices=num_devices
      )
  
      bn1.initialize(device=device_list[0])
      bn2.initialize(device=device_list)
  
      # using the same values for gamma and beta
      # _syncParameters(_find_bn(bn1), _find_bn(bn2), device_list[0])
  
      input1.attach_grad()
      inputs2 = split_and_load(input2, device_list, batch_axis=0)
      for xi in inputs2:
          xi.attach_grad()
  
      with mx.autograd.record():
          output1 = bn1(input1)
          output2 = [bn2(xi) for xi in inputs2]
          loss1 = (output1**2).sum()
          loss2 = [(output**2).sum() for output in output2]
          mx.autograd.backward(loss1)
          mx.autograd.backward(loss2)
  
      output2 = mx.np.concatenate(
          [output.to_device(input.context) for output in output2],
          axis=0,
      )
      # assert forwarding
      assert_almost_equal(input1, input2, atol=1e-3, rtol=1e-3)
      assert_almost_equal(output1, output2, atol=1e-3, rtol=1e-3)
      assert_almost_equal(
          _find_bn(bn1).running_mean.data(device_list[0]),
          _find_bn(bn2).running_mean.data(device_list[0]),
          atol=1e-3,
          rtol=1e-3,
      )
      assert_almost_equal(
          _find_bn(bn1).running_var.data(device_list[0]),
          _find_bn(bn2).running_var.data(device_list[0]),
          atol=1e-3,
          rtol=1e-3,
      )
      input2grad = mx.np.concatenate(
          [output.grad.to_device(input.context) for output in inputs2],
          axis=0,
      )
      assert_almost_equal(input1.grad, input2grad, atol=1e-3, rtol=1e-3)
  
imports: import sys
  import os
  import time
  import random
  import mxnet
  import multiprocessing
  from mxnet.test_utils import check_consistency, set_default_device, assert_almost_equal, rand_ndarray, environment
  import numpy
  import math
  from mxnet import autograd
  import pytest
  from common import assert_raises_cudnn_not_satisfied, run_in_spawned_process, random_seed
  from test_gluon import *
  from test_loss import *
  from test_numpy_loss import *
  from test_gluon_rnn import *
label_desc: Use image node_id 14 for calling a global function with example usage: _check_batchnorm_result(input, num_devices, cuda) and returns: module, module