import cupy


def pad(array, pad_width, mode=None, **kwargs):
    if mode != 'constant':
        raise NotImplementedError

    if kwargs.keys() == []:
        fill_value = 0
    elif kwargs.keys() == ['constant_values']:
        if not isinstance(kwargs['constant_values'], int):
            raise NotImplementedError
        fill_value = kwargs['constant_values']
    else:
        raise NotImplementedError

    if isinstance(pad_width, int):
        shape = tuple([s + pad_width * 2 for s in array.shape])
        ret = cupy.full(shape, fill_value, dtype=array.dtype)
        index = tuple([slice(pad_width, pad_width + s) for s in array.shape])
        ret[index] = array
    elif isinstance(pad_width, (list, tuple, cupy.ndarray)):
        if array.ndim == len(pad_width):
            shape = tuple([s + pad_width[i] * 2
                          for i, s in enumerate(array.shape)])
            ret = cupy.full(shape, fill_value,
                            dtype=array.dtype)
            index = tuple([slice(pad_width[i], pad_width[i] + s)
                          for i, s in enumerate(array.shape)])
            ret[index] = array
        elif array.ndim == 1 and len(pad_width) == 2:
            front = cupy.zeros(pad_width[0])  # fix
            end = cupy.zeros(pad_width[1])  # fix
            ret = cupy.hstack((cupy.hstack((front, array)), end))
        else:
            fmt = 'Unable to create correctly shaped tuple from %s'
            raise ValueError(fmt % (shape,))
    else:
        raise TypeError('`pad_width` must be of integral type.')
    return ret

@@ -120,170 +120,90 @@
 ror%0A
-%0A
     
-if kwargs.keys() == %5B%5D:%0A        fill_value = 0%0A    elif kwargs.keys() == %5B'constant_values'%5D:%0A        if not isinstance(kwargs%5B'constant_values'%5D, int):%0A    
+constant_value = kwargs.pop('constant_values', None)%0A    if len(kwargs) != 0:%0A
     
@@ -240,33 +240,43 @@
     
-    fill_value = kwargs%5B'
+if constant_value is None:%0A        
 cons
@@ -289,20 +289,55 @@
 alue
-s'%5D
+ = 0
 %0A    
-else
+if not isinstance(constant_value, int)
 :%0A  
@@ -368,17 +368,16 @@
 edError%0A
-%0A
     if i
@@ -494,28 +494,32 @@
 full(shape, 
-fill
+constant
 _value, dtyp
@@ -890,12 +890,16 @@
 pe, 
-fill
+constant
 _val
@@ -1207,22 +1207,32 @@
 dth%5B0%5D) 
- # fix
++ constant_value
 %0A       
@@ -1271,14 +1271,24 @@
 1%5D) 
- # fix
++ constant_value
 %0A   
@@ -1302,29 +1302,16 @@
   ret = 
-cupy.hstack((
 cupy.hst
@@ -1327,18 +1327,16 @@
 t, array
-))
 , end))%0A

fix constant_values