prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  EOFError: Ran out of input
  When running example and solving "Can't import fetch from utils" issue, this one comes up:
  
  ![](https://user-images.githubusercontent.com/55894077/98364197-a42f1480-2030-11eb-99c8-d0784873ae22.png)
  
  
  </issue>
  <code>
  [start of tinygrad/utils.py]
  1 import numpy as np
  2 
  3 def mask_like(like, mask_inx, mask_value = 1.0):
  4   mask = np.zeros_like(like).reshape(-1)
  5   mask[mask_inx] = mask_value
  6   return mask.reshape(like.shape)
  7 
  8 def layer_init_uniform(*x):
  9   ret = np.random.uniform(-1., 1., size=x)/np.sqrt(np.prod(x))
  10   return ret.astype(np.float32)
  11 
  12 def fetch(url):
  13   import requests, os, hashlib, tempfile
  14   fp = os.path.join(tempfile.gettempdir(), hashlib.md5(url.encode('utf-8')).hexdigest())    
  15   if os.path.isfile(fp):
  16     with open(fp, "rb") as f:
  17       dat = f.read()
  18   else:
  19     print("fetching %s" % url)
  20     with open(fp+".tmp", "wb") as f:
  21       dat = requests.get(url).content
  22       f.write(dat)
  23     os.rename(fp+".tmp", fp)
  24   return dat
  25 
  26 def fetch_mnist():
  27   import gzip
  28   parse = lambda dat: np.frombuffer(gzip.decompress(dat), dtype=np.uint8).copy()
  29   X_train = parse(fetch("http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz"))[0x10:].reshape((-1, 28, 28))
  30   Y_train = parse(fetch("http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz"))[8:]
  31   X_test = parse(fetch("http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz"))[0x10:].reshape((-1, 28, 28))
  32   Y_test = parse(fetch("http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz"))[8:]
  33   return X_train, Y_train, X_test, Y_test
  34 
  35
  [end of tinygrad/utils.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/tinygrad/utils.py b/tinygrad/utils.py
  --- a/tinygrad/utils.py
  +++ b/tinygrad/utils.py
  @@ -1,4 +1,5 @@
   import numpy as np
  +import os
   
   def mask_like(like, mask_inx, mask_value = 1.0):
     mask = np.zeros_like(like).reshape(-1)
  @@ -12,7 +13,7 @@
   def fetch(url):
     import requests, os, hashlib, tempfile
     fp = os.path.join(tempfile.gettempdir(), hashlib.md5(url.encode('utf-8')).hexdigest())    
  -  if os.path.isfile(fp):
  +  if os.path.isfile(fp) and os.stat(fp).st_size > 0:
       with open(fp, "rb") as f:
         dat = f.read()
     else:
  
verification_info: {"golden_diff": "diff --git a/tinygrad/utils.py b/tinygrad/utils.py\n--- a/tinygrad/utils.py\n+++ b/tinygrad/utils.py\n@@ -1,4 +1,5 @@\n import numpy as np\n+import os\n \n def mask_like(like, mask_inx, mask_value = 1.0):\n   mask = np.zeros_like(like).reshape(-1)\n@@ -12,7 +13,7 @@\n def fetch(url):\n   import requests, os, hashlib, tempfile\n   fp = os.path.join(tempfile.gettempdir(), hashlib.md5(url.encode('utf-8')).hexdigest())    \n-  if os.path.isfile(fp):\n+  if os.path.isfile(fp) and os.stat(fp).st_size > 0:\n     with open(fp, \"rb\") as f:\n       dat = f.read()\n   else:\n", "issue": "EOFError: Ran out of input\nWhen running example and solving \"Can't import fetch from utils\" issue, this one comes up:\r\n\r\n![](https://user-images.githubusercontent.com/55894077/98364197-a42f1480-2030-11eb-99c8-d0784873ae22.png)\r\n\n", "before_files": [{"content": "import numpy as np\n\ndef mask_like(like, mask_inx, mask_value = 1.0):\n  mask = np.zeros_like(like).reshape(-1)\n  mask[mask_inx] = mask_value\n  return mask.reshape(like.shape)\n\ndef layer_init_uniform(*x):\n  ret = np.random.uniform(-1., 1., size=x)/np.sqrt(np.prod(x))\n  return ret.astype(np.float32)\n\ndef fetch(url):\n  import requests, os, hashlib, tempfile\n  fp = os.path.join(tempfile.gettempdir(), hashlib.md5(url.encode('utf-8')).hexdigest())    \n  if os.path.isfile(fp):\n    with open(fp, \"rb\") as f:\n      dat = f.read()\n  else:\n    print(\"fetching %s\" % url)\n    with open(fp+\".tmp\", \"wb\") as f:\n      dat = requests.get(url).content\n      f.write(dat)\n    os.rename(fp+\".tmp\", fp)\n  return dat\n\ndef fetch_mnist():\n  import gzip\n  parse = lambda dat: np.frombuffer(gzip.decompress(dat), dtype=np.uint8).copy()\n  X_train = parse(fetch(\"http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz\"))[0x10:].reshape((-1, 28, 28))\n  Y_train = parse(fetch(\"http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz\"))[8:]\n  X_test = parse(fetch(\"http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz\"))[0x10:].reshape((-1, 28, 28))\n  Y_test = parse(fetch(\"http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz\"))[8:]\n  return X_train, Y_train, X_test, Y_test\n\n", "path": "tinygrad/utils.py"}]}