code: def _ctensor_eq_ndarray(t1, np1):
      d = t1.device()
      t1.ToHost()
      if t1.data_type() == singa_api.kInt:
          np.testing.assert_array_almost_equal(
              t1.GetIntValue(t1.Size()), np1.flatten()
          )
      elif t1.data_type() == singa_api.kFloat32:
          np.testing.assert_array_almost_equal(
              t1.GetFloatValue(t1.Size()), np1.flatten()
          )
  
      if np1.dtype == np.float32:
          np.testing.assert_equal(t1.data_type(), singa_api.kFloat32)
      elif np1.dtype == np.int32:
          np.testing.assert_equal(t1.data_type(), singa_api.kInt)
  
      np.testing.assert_array_almost_equal(t1.shape(), np1.shape)
      t1.ToDevice(d)
  
imports: from __future__ import division
  import unittest
  import math
  import numpy
  from singa import singa_wrap
  from singa import tensor
  from cuda_helper import gpu_dev, cpu_dev
label_desc: Use image node_id 4 for calling a global function with example usage: _ctensor_eq_ndarray(t1, np1) without return types