code: def test_batch_norm(self):
      x_shape = [2, 2]
      x = singa_wrap.Tensor(x_shape)
      x.CopyFloatDataFromHostPtr([1, 2, 3, 4])
  
      dy_shape = [2, 2]
      dy = singa_wrap.Tensor(dy_shape)
      dy.CopyFloatDataFromHostPtr([4, 3, 2, 1])
  
      scale_shape = [2]
      scale = singa_wrap.Tensor(scale_shape)
      scale.CopyFloatDataFromHostPtr([1, 1])
  
      bias_shape = [2]
      bias = singa_wrap.Tensor(bias_shape)
      bias.CopyFloatDataFromHostPtr([0, 0])
  
      mean_shape = [2]
      mean = singa_wrap.Tensor(mean_shape)
      mean.CopyFloatDataFromHostPtr([1, 2])
      var = singa_wrap.Tensor(mean_shape)
      var.CopyFloatDataFromHostPtr([1, 2])
  
      handle = singa_wrap.BatchNormHandle(0.9, x)
  
      # 2D Forward Inference
      y = singa_wrap.CpuBatchNormForwardInference(
          handle, x, scale, bias, mean, var
      )
      self.assertListEqual([2, 2], list(y.shape()))
  
      # 2D Forward Training
      (
          y,
          mean_updated,
          var_updated,
      ) = singa_wrap.CpuBatchNormForwardTraining(
          handle, x, scale, bias, mean, var
      )
      self.assertListEqual([2, 2], list(y.shape()))
      self.assertListEqual([2], list(mean_updated.shape()))
      self.assertListEqual([2], list(var_updated.shape()))
  
      # 2D Backward dx
      (dx, dscale, dbias) = singa_wrap.CpuBatchNormBackwardx(
          handle, y, dy, x, scale, bias, mean_updated, var_updated
      )
      self.assertListEqual([2, 2], list(dx.shape()))
      self.assertListEqual([2], list(dscale.shape()))
      self.assertListEqual([2], list(dbias.shape()))
  
      # 4D Forward Inference
  
      x2_shape = [1, 2, 4, 4]
      x2 = singa_wrap.Tensor(x2_shape)
      x2.CopyFloatDataFromHostPtr(
          [
              0.0736655,
              0.0459045,
              0.0779517,
              0.0771059,
              0.0586862,
              0.0561263,
              0.0708457,
              0.0977273,
              0.0405025,
              -0.170897,
              0.0208982,
              0.136865,
              -0.0367905,
              -0.0618205,
              -0.0103908,
              -0.0522777,
              -0.122161,
              -0.025427,
              -0.0718576,
              -0.185941,
              0.0166533,
              0.178679,
              -0.0576606,
              -0.137817,
              0.150676,
              0.153442,
              -0.0929899,
              -0.148675,
              -0.112459,
              -0.106284,
              -0.103074,
              -0.0668811,
          ]
      )
  
      handle = singa_wrap.BatchNormHandle(0.9, x)
      y2 = singa_wrap.CpuBatchNormForwardInference(
          handle, x2, scale, bias, mean, var
      )
      self.assertListEqual([1, 2, 4, 4], list(y2.shape()))
  
imports: import unittest
  from singa import singa_wrap
label_desc: Use image node_id 3 for calling the TestPythonOperation obj's underlying member method code with example usage: obj.test_batch_norm() without return types