def get_array_module(*args):
 for arg in args:
  if isinstance(arg, ndarray):
   return _cupy
 return numpy

def get_array_module ( * args ) : for arg in args : if isinstance ( arg , ndarray ) : return _cupy return numpy
gets an appropriate one from :mod:numpy or :mod:cupy .