prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Add type check to LeakyReLU function
  Related to #123 
  
  
  </issue>
  <code>
  [start of chainer/functions/leaky_relu.py]
  1 from chainer import cuda
  2 from chainer import function
  3 
  4 
  5 def _kern():
  6     return cuda.elementwise(
  7         'float* y, const float* cond, const float* x, float slope',
  8         'y[i] = cond[i] >= 0 ? x[i] : slope * x[i]', 'lrelu')
  9 
  10 
  11 class LeakyReLU(function.Function):
  12 
  13     """Leaky rectifier unit."""
  14 
  15     def __init__(self, slope=0.2):
  16         self.slope = slope
  17 
  18     def forward_cpu(self, x):
  19         y = x[0].copy()
  20         y[x[0] < 0] *= self.slope
  21         return y,
  22 
  23     def forward_gpu(self, x):
  24         y = cuda.empty_like(x[0])
  25         _kern()(y, x[0], x[0], self.slope)
  26         return y,
  27 
  28     def backward_cpu(self, x, gy):
  29         gx = gy[0].copy()
  30         gx[x[0] < 0] *= self.slope
  31         return gx,
  32 
  33     def backward_gpu(self, x, gy):
  34         gx = cuda.empty_like(x[0])
  35         _kern()(gx, x[0], gy[0], self.slope)
  36         return gx,
  37 
  38 
  39 def leaky_relu(x, slope=0.2):
  40     """Leaky Rectified Linear Unit function.
  41 
  42     This function is expressed as :math:`f(x) = \max(x, ax)`, where :math:`a`
  43     is a configurable slope value.
  44 
  45     Args:
  46         x (~chainer.Variable): Input variable.
  47         slope (float): Slope value :math:`a`.
  48 
  49     Returns:
  50         ~chainer.Variable: Output variable.
  51 
  52     """
  53     return LeakyReLU(slope)(x)
  54
  [end of chainer/functions/leaky_relu.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/chainer/functions/leaky_relu.py b/chainer/functions/leaky_relu.py
  --- a/chainer/functions/leaky_relu.py
  +++ b/chainer/functions/leaky_relu.py
  @@ -1,5 +1,8 @@
  +import numpy
  +
   from chainer import cuda
   from chainer import function
  +from chainer.utils import type_check
   
   
   def _kern():
  @@ -15,6 +18,13 @@
       def __init__(self, slope=0.2):
           self.slope = slope
   
  +    def check_type_forward(self, in_types):
  +        type_check.expect(in_types.size() == 1)
  +        x_type, = in_types
  +        type_check.expect(
  +            x_type.dtype == numpy.float32,
  +        )
  +
       def forward_cpu(self, x):
           y = x[0].copy()
           y[x[0] < 0] *= self.slope
  
verification_info: {"golden_diff": "diff --git a/chainer/functions/leaky_relu.py b/chainer/functions/leaky_relu.py\n--- a/chainer/functions/leaky_relu.py\n+++ b/chainer/functions/leaky_relu.py\n@@ -1,5 +1,8 @@\n+import numpy\n+\n from chainer import cuda\n from chainer import function\n+from chainer.utils import type_check\n \n \n def _kern():\n@@ -15,6 +18,13 @@\n     def __init__(self, slope=0.2):\n         self.slope = slope\n \n+    def check_type_forward(self, in_types):\n+        type_check.expect(in_types.size() == 1)\n+        x_type, = in_types\n+        type_check.expect(\n+            x_type.dtype == numpy.float32,\n+        )\n+\n     def forward_cpu(self, x):\n         y = x[0].copy()\n         y[x[0] < 0] *= self.slope\n", "issue": "Add type check to LeakyReLU function\nRelated to #123 \n\n", "before_files": [{"content": "from chainer import cuda\nfrom chainer import function\n\n\ndef _kern():\n    return cuda.elementwise(\n        'float* y, const float* cond, const float* x, float slope',\n        'y[i] = cond[i] >= 0 ? x[i] : slope * x[i]', 'lrelu')\n\n\nclass LeakyReLU(function.Function):\n\n    \"\"\"Leaky rectifier unit.\"\"\"\n\n    def __init__(self, slope=0.2):\n        self.slope = slope\n\n    def forward_cpu(self, x):\n        y = x[0].copy()\n        y[x[0] < 0] *= self.slope\n        return y,\n\n    def forward_gpu(self, x):\n        y = cuda.empty_like(x[0])\n        _kern()(y, x[0], x[0], self.slope)\n        return y,\n\n    def backward_cpu(self, x, gy):\n        gx = gy[0].copy()\n        gx[x[0] < 0] *= self.slope\n        return gx,\n\n    def backward_gpu(self, x, gy):\n        gx = cuda.empty_like(x[0])\n        _kern()(gx, x[0], gy[0], self.slope)\n        return gx,\n\n\ndef leaky_relu(x, slope=0.2):\n    \"\"\"Leaky Rectified Linear Unit function.\n\n    This function is expressed as :math:`f(x) = \\max(x, ax)`, where :math:`a`\n    is a configurable slope value.\n\n    Args:\n        x (~chainer.Variable): Input variable.\n        slope (float): Slope value :math:`a`.\n\n    Returns:\n        ~chainer.Variable: Output variable.\n\n    \"\"\"\n    return LeakyReLU(slope)(x)\n", "path": "chainer/functions/leaky_relu.py"}]}