from functools import wraps

from chainer import cuda
import numpy as np

class xpmeta(type):
    def __new__(cls, clsname, bases, clsdict):
        try:
            cuda.check_cuda_available()
            xp = cuda.cupy
        except RuntimeError:
            xp = np
        return xp

class xp(metaclass=xpmeta):
    pass

@@ -51,26 +51,203 @@
 uda%0A
-import numpy as np
+from chainer import Variable%0Aimport numpy as np%0A%0Adef wrap_variable(func):%0A    @wraps(func)%0A    def wrapper(*args, **kwargs):%0A        result = func(*args, **kwargs)%0A        return Variable(result)
 %0A%0Acl

add new decorator