prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  jax missing scipy.special.expit
  Would be possible to add gradients for `expit` and `logit`?
  
  </issue>
  <code>
  [start of jax/scipy/special.py]
  1 # Copyright 2018 Google LLC
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     https://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 from __future__ import absolute_import
  16 from __future__ import division
  17 from __future__ import print_function
  18 
  19 import scipy.special as osp_special
  20 
  21 from .. import lax
  22 from ..numpy.lax_numpy import _wraps
  23 
  24 
  25 # need to create new functions because _wraps sets the __name__ attribute
  26 gammaln = _wraps(osp_special.gammaln)(lambda x: lax.lgamma(x))
  27 digamma = _wraps(osp_special.digamma)(lambda x: lax.digamma(x))
  28 erf = _wraps(osp_special.erf)(lambda x: lax.erf(x))
  29 erfc = _wraps(osp_special.erfc)(lambda x: lax.erfc(x))
  30 erfinv = _wraps(osp_special.erfinv)(lambda x: lax.erf_inv(x))
  31
  [end of jax/scipy/special.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/jax/scipy/special.py b/jax/scipy/special.py
  --- a/jax/scipy/special.py
  +++ b/jax/scipy/special.py
  @@ -19,7 +19,7 @@
   import scipy.special as osp_special
   
   from .. import lax
  -from ..numpy.lax_numpy import _wraps
  +from ..numpy.lax_numpy import _wraps, asarray
   
   
   # need to create new functions because _wraps sets the __name__ attribute
  @@ -28,3 +28,16 @@
   erf = _wraps(osp_special.erf)(lambda x: lax.erf(x))
   erfc = _wraps(osp_special.erfc)(lambda x: lax.erfc(x))
   erfinv = _wraps(osp_special.erfinv)(lambda x: lax.erf_inv(x))
  +
  +
  +@_wraps(osp_special.logit)
  +def logit(x):
  +  x = asarray(x)
  +  return lax.log(lax.div(x, lax.sub(lax._const(x, 1), x)))
  +
  +
  +@_wraps(osp_special.expit)
  +def expit(x):
  +  x = asarray(x)
  +  one = lax._const(x, 1)
  +  return lax.div(one, lax.add(one, lax.exp(lax.neg(x))))
  
verification_info: {"golden_diff": "diff --git a/jax/scipy/special.py b/jax/scipy/special.py\n--- a/jax/scipy/special.py\n+++ b/jax/scipy/special.py\n@@ -19,7 +19,7 @@\n import scipy.special as osp_special\n \n from .. import lax\n-from ..numpy.lax_numpy import _wraps\n+from ..numpy.lax_numpy import _wraps, asarray\n \n \n # need to create new functions because _wraps sets the __name__ attribute\n@@ -28,3 +28,16 @@\n erf = _wraps(osp_special.erf)(lambda x: lax.erf(x))\n erfc = _wraps(osp_special.erfc)(lambda x: lax.erfc(x))\n erfinv = _wraps(osp_special.erfinv)(lambda x: lax.erf_inv(x))\n+\n+\n+@_wraps(osp_special.logit)\n+def logit(x):\n+  x = asarray(x)\n+  return lax.log(lax.div(x, lax.sub(lax._const(x, 1), x)))\n+\n+\n+@_wraps(osp_special.expit)\n+def expit(x):\n+  x = asarray(x)\n+  one = lax._const(x, 1)\n+  return lax.div(one, lax.add(one, lax.exp(lax.neg(x))))\n", "issue": "jax missing scipy.special.expit\nWould be possible to add gradients for `expit` and `logit`?\n", "before_files": [{"content": "# Copyright 2018 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport scipy.special as osp_special\n\nfrom .. import lax\nfrom ..numpy.lax_numpy import _wraps\n\n\n# need to create new functions because _wraps sets the __name__ attribute\ngammaln = _wraps(osp_special.gammaln)(lambda x: lax.lgamma(x))\ndigamma = _wraps(osp_special.digamma)(lambda x: lax.digamma(x))\nerf = _wraps(osp_special.erf)(lambda x: lax.erf(x))\nerfc = _wraps(osp_special.erfc)(lambda x: lax.erfc(x))\nerfinv = _wraps(osp_special.erfinv)(lambda x: lax.erf_inv(x))\n", "path": "jax/scipy/special.py"}]}