import unittest

import numpy

import cupy
from cupy import testing


@testing.gpu
class TestCount(unittest.TestCase):

    _multiprocess_can_split_ = True

    @testing.for_all_dtypes()
    def test_count_nonzero(self, dtype):
        m = testing.shaped_random((2, 3), numpy, bool)
        a = testing.shaped_random((2, 3), numpy, dtype) * m
        c = numpy.count_nonzero(a)
        d = cupy.count_nonzero(cupy.array(a))
        self.assertEqual(d, c)

    @testing.for_all_dtypes()
    @testing.numpy_cupy_allclose(type_check=False)
    def test_count_nonzero_zero_dim(self, xp, dtype):
        a = xp.array(1.0, dtype=dtype)
        c = xp.count_nonzero(a)
        self.assertIsInstance(c, int)
        return c

@@ -14,34 +14,8 @@
 st%0A%0A
-import numpy%0A%0Aimport cupy%0A
 from
@@ -150,24 +150,75 @@
 ll_dtypes()%0A
+    @testing.numpy_cupy_allclose(type_check=False)%0A
     def test
@@ -237,16 +237,20 @@
 ro(self,
+ xp,
  dtype):
@@ -296,19 +296,20 @@
 3), 
-numpy, 
+xp, xp.
 bool
+_
 )%0A  
@@ -348,21 +348,18 @@
 (2, 3), 
-numpy
+xp
 , dtype)
@@ -375,21 +375,18 @@
     c = 
-numpy
+xp
 .count_n
@@ -407,76 +407,54 @@
     
-d = cupy.count_nonzero(cupy.array(a))%0A        self.assertEqual(d,
+self.assertIsInstance(c, int)%0A        return
  c
-)
 %0A%0A  

Revert the test code