We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `tinygrad/utils.py`
Content:
```
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 FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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:

{"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"}], "after_files": [{"content": "import numpy as np\nimport os\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) and os.stat(fp).st_size > 0:\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"}]}