code: def read_data(label, image):
      
      base_url = 'http://yann.lecun.com/exdb/mnist/'
      with gzip.open(download_file(base_url+label, os.path.join('data',label))) as flbl:
          magic, num = struct.unpack(">II", flbl.read(8))
          label = np.fromstring(flbl.read(), dtype=np.int8)
      with gzip.open(download_file(base_url+image, os.path.join('data',image)), 'rb') as fimg:
          magic, num, rows, cols = struct.unpack(">IIII", fimg.read(16))
          image = np.fromstring(fimg.read(), dtype=np.uint8).reshape(len(label), rows, cols)
      return (label, image)
docs: download and read data into numpy