We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
tf.data.Dataset not support! [bug]
<!---
**If you are reporting a bug:**
*  Verify that your issue is not being currently addressed by other issues or pull requests.
*  Please note that Auto-Keras is only compatible with **Python 3.6**.
*  Tag the issue with the `bug report` tag.
-->

### Bug Description
<!---
A clear and concise description of what the bug is.
-->
run with tensorflow_datasets 's mnist dataset, but show error message:
AttributeError: 'TakeDataset' object has no attribute 'shape'

### Reproducing Steps
```
# run codes:
import tensorflow_datasets as tfds
mnist_train = tfds.load('mnist', split="train", as_supervised=True)
import autokeras as ak
ak0 = ak.ImageClassifier(num_classes=10, max_trials=10)
ak0.fit(mnist_train, epochs=10)
```
### Expected Behavior
<!--
A clear and concise description of what you expected to happen.
-->
```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-a90e48684d55> in <module>
----> 1 ak0.fit(mnist_train, epochs=10)

~/anaconda3/lib/python3.7/site-packages/autokeras/tasks/image.py in fit(self, x, y, epochs, callbacks, validation_split, validation_data, **kwargs)
    119                     validation_split=validation_split,
    120                     validation_data=validation_data,
--> 121                     **kwargs)
    122 
    123 

~/anaconda3/lib/python3.7/site-packages/autokeras/auto_model.py in fit(self, x, y, batch_size, epochs, callbacks, validation_split, validation_data, **kwargs)
    229             y=y,
    230             validation_data=validation_data,
--> 231             validation_split=validation_split)
    232 
    233         # Process the args.

~/anaconda3/lib/python3.7/site-packages/autokeras/auto_model.py in _prepare_data(self, x, y, validation_data, validation_split)
    303         # TODO: Handle other types of input, zip dataset, tensor, dict.
    304         # Prepare the dataset.
--> 305         dataset = self._process_xy(x, y, True)
    306         if validation_data:
    307             self._split_dataset = False

~/anaconda3/lib/python3.7/site-packages/autokeras/auto_model.py in _process_xy(self, x, y, fit)
    291 
    292         x = self._process_x(x, fit)
--> 293         y = self._process_y(y, fit)
    294 
    295         return tf.data.Dataset.zip((x, y))

~/anaconda3/lib/python3.7/site-packages/autokeras/auto_model.py in _process_y(self, y, fit)
    267         for data, head, adapter in zip(y, self._heads, self._output_adapters):
    268             if fit:
--> 269                 data = adapter.fit_transform(data)
    270             else:
    271                 data = adapter.transform(data)

~/anaconda3/lib/python3.7/site-packages/autokeras/engine/adapter.py in fit_transform(self, dataset)
     66     def fit_transform(self, dataset):
     67         self.check(dataset)
---> 68         self.fit_before_convert(dataset)
     69         dataset = self.convert_to_dataset(dataset)
     70         self.fit(dataset)

~/anaconda3/lib/python3.7/site-packages/autokeras/adapters/output_adapter.py in fit_before_convert(self, dataset)
     65         if isinstance(dataset, tf.data.Dataset):
     66             if not self.num_classes:
---> 67                 shape = dataset.take(1).shape[1]
     68                 if shape == 1:
     69                     self.num_classes = 2

AttributeError: 'TakeDataset' object has no attribute 'shape'
```
### Setup Details
Include the details about the versions of:
 - OS type and version:
 - Python: 
 - autokeras: 1.0.1
 - scikit-learn:
 - numpy:
 - keras:
 - scipy:
 - tensorflow: 2.1.0
 - pytorch:

### Additional context
<!---
Add any other context about the problem here.
-->
TakeDataset doesn't have attribute 'shape', so the code may be wrong. You can also find I have set num_classes=10, so there are several bugs, not just one.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `autokeras/adapters/output_adapter.py`
Content:
```
1 import numpy as np
2 import pandas as pd
3 import tensorflow as tf
4 
5 from autokeras import encoders
6 from autokeras.engine import adapter as adapter_module
7 
8 
9 class HeadAdapter(adapter_module.Adapter):
10 
11     def __init__(self, name, **kwargs):
12         super().__init__(**kwargs)
13         self.name = name
14 
15     def check(self, dataset):
16         supported_types = (tf.data.Dataset, np.ndarray, pd.DataFrame, pd.Series)
17         if not isinstance(dataset, supported_types):
18             raise TypeError('Expect the target data of {name} to be tf.data.Dataset,'
19                             ' np.ndarray, pd.DataFrame or pd.Series, but got {type}.'
20                             .format(name=self.name, type=type(dataset)))
21 
22     def convert_to_dataset(self, dataset):
23         if isinstance(dataset, np.ndarray):
24             if len(dataset.shape) == 1:
25                 dataset = dataset.reshape(-1, 1)
26         if isinstance(dataset, pd.DataFrame):
27             dataset = dataset.values
28         if isinstance(dataset, pd.Series):
29             dataset = dataset.values.reshape(-1, 1)
30         return super().convert_to_dataset(dataset)
31 
32     def postprocess(self, y):
33         """Postprocess the output of the Keras Model."""
34         return y
35 
36     def get_config(self):
37         config = super().get_config()
38         config.update({
39             'name': self.name,
40         })
41         return config
42 
43 
44 class ClassificationHeadAdapter(HeadAdapter):
45 
46     def __init__(self, num_classes=None, **kwargs):
47         super().__init__(**kwargs)
48         self.num_classes = num_classes
49         self.label_encoder = None
50 
51     def get_config(self):
52         config = super().get_config()
53         config.update({
54             'encoder': encoders.serialize(self.label_encoder),
55         })
56         return config
57 
58     @classmethod
59     def from_config(cls, config):
60         obj = super().from_config(config)
61         obj.label_encoder = encoders.deserialize(config['encoder'])
62 
63     def fit_before_convert(self, dataset):
64         # If in tf.data.Dataset, must be encoded already.
65         if isinstance(dataset, tf.data.Dataset):
66             if not self.num_classes:
67                 shape = dataset.take(1).shape[1]
68                 if shape == 1:
69                     self.num_classes = 2
70                 else:
71                     self.num_classes = shape
72             return
73         if isinstance(dataset, pd.DataFrame):
74             dataset = dataset.values
75         if isinstance(dataset, pd.Series):
76             dataset = dataset.values.reshape(-1, 1)
77         # Not label.
78         if len(dataset.flatten()) != len(dataset):
79             self.num_classes = dataset.shape[1]
80             return
81         labels = set(dataset.flatten())
82         if self.num_classes is None:
83             self.num_classes = len(labels)
84         if self.num_classes == 2:
85             self.label_encoder = encoders.LabelEncoder()
86         elif self.num_classes > 2:
87             self.label_encoder = encoders.OneHotEncoder()
88         elif self.num_classes < 2:
89             raise ValueError('Expect the target data for {name} to have '
90                              'at least 2 classes, but got {num_classes}.'
91                              .format(name=self.name, num_classes=self.num_classes))
92         self.label_encoder.fit(dataset)
93 
94     def convert_to_dataset(self, dataset):
95         if self.label_encoder:
96             dataset = self.label_encoder.encode(dataset)
97         return super().convert_to_dataset(dataset)
98 
99     def postprocess(self, y):
100         if self.label_encoder:
101             y = self.label_encoder.decode(y)
102         return y
103 
104 
105 class RegressionHeadAdapter(HeadAdapter):
106     pass
107
```
--- 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/autokeras/adapters/output_adapter.py b/autokeras/adapters/output_adapter.py
--- a/autokeras/adapters/output_adapter.py
+++ b/autokeras/adapters/output_adapter.py
@@ -3,6 +3,7 @@
 import tensorflow as tf
 
 from autokeras import encoders
+from autokeras import utils
 from autokeras.engine import adapter as adapter_module
 
 
@@ -64,7 +65,8 @@
         # If in tf.data.Dataset, must be encoded already.
         if isinstance(dataset, tf.data.Dataset):
             if not self.num_classes:
-                shape = dataset.take(1).shape[1]
+                shape = utils.dataset_shape(dataset)[0]
+                # Single column with 0s and 1s.
                 if shape == 1:
                     self.num_classes = 2
                 else:

{"golden_diff": "diff --git a/autokeras/adapters/output_adapter.py b/autokeras/adapters/output_adapter.py\n--- a/autokeras/adapters/output_adapter.py\n+++ b/autokeras/adapters/output_adapter.py\n@@ -3,6 +3,7 @@\n import tensorflow as tf\n \n from autokeras import encoders\n+from autokeras import utils\n from autokeras.engine import adapter as adapter_module\n \n \n@@ -64,7 +65,8 @@\n         # If in tf.data.Dataset, must be encoded already.\n         if isinstance(dataset, tf.data.Dataset):\n             if not self.num_classes:\n-                shape = dataset.take(1).shape[1]\n+                shape = utils.dataset_shape(dataset)[0]\n+                # Single column with 0s and 1s.\n                 if shape == 1:\n                     self.num_classes = 2\n                 else:\n", "issue": "tf.data.Dataset not support! [bug]\n<!---\r\n**If you are reporting a bug:**\r\n*  Verify that your issue is not being currently addressed by other issues or pull requests.\r\n*  Please note that Auto-Keras is only compatible with **Python 3.6**.\r\n*  Tag the issue with the `bug report` tag.\r\n-->\r\n\r\n### Bug Description\r\n<!---\r\nA clear and concise description of what the bug is.\r\n-->\r\nrun with tensorflow_datasets 's mnist dataset, but show error message:\r\nAttributeError: 'TakeDataset' object has no attribute 'shape'\r\n\r\n### Reproducing Steps\r\n```\r\n# run codes:\r\nimport tensorflow_datasets as tfds\r\nmnist_train = tfds.load('mnist', split=\"train\", as_supervised=True)\r\nimport autokeras as ak\r\nak0 = ak.ImageClassifier(num_classes=10, max_trials=10)\r\nak0.fit(mnist_train, epochs=10)\r\n```\r\n### Expected Behavior\r\n<!--\r\nA clear and concise description of what you expected to happen.\r\n-->\r\n```\r\n---------------------------------------------------------------------------\r\nAttributeError                            Traceback (most recent call last)\r\n<ipython-input-4-a90e48684d55> in <module>\r\n----> 1 ak0.fit(mnist_train, epochs=10)\r\n\r\n~/anaconda3/lib/python3.7/site-packages/autokeras/tasks/image.py in fit(self, x, y, epochs, callbacks, validation_split, validation_data, **kwargs)\r\n    119                     validation_split=validation_split,\r\n    120                     validation_data=validation_data,\r\n--> 121                     **kwargs)\r\n    122 \r\n    123 \r\n\r\n~/anaconda3/lib/python3.7/site-packages/autokeras/auto_model.py in fit(self, x, y, batch_size, epochs, callbacks, validation_split, validation_data, **kwargs)\r\n    229             y=y,\r\n    230             validation_data=validation_data,\r\n--> 231             validation_split=validation_split)\r\n    232 \r\n    233         # Process the args.\r\n\r\n~/anaconda3/lib/python3.7/site-packages/autokeras/auto_model.py in _prepare_data(self, x, y, validation_data, validation_split)\r\n    303         # TODO: Handle other types of input, zip dataset, tensor, dict.\r\n    304         # Prepare the dataset.\r\n--> 305         dataset = self._process_xy(x, y, True)\r\n    306         if validation_data:\r\n    307             self._split_dataset = False\r\n\r\n~/anaconda3/lib/python3.7/site-packages/autokeras/auto_model.py in _process_xy(self, x, y, fit)\r\n    291 \r\n    292         x = self._process_x(x, fit)\r\n--> 293         y = self._process_y(y, fit)\r\n    294 \r\n    295         return tf.data.Dataset.zip((x, y))\r\n\r\n~/anaconda3/lib/python3.7/site-packages/autokeras/auto_model.py in _process_y(self, y, fit)\r\n    267         for data, head, adapter in zip(y, self._heads, self._output_adapters):\r\n    268             if fit:\r\n--> 269                 data = adapter.fit_transform(data)\r\n    270             else:\r\n    271                 data = adapter.transform(data)\r\n\r\n~/anaconda3/lib/python3.7/site-packages/autokeras/engine/adapter.py in fit_transform(self, dataset)\r\n     66     def fit_transform(self, dataset):\r\n     67         self.check(dataset)\r\n---> 68         self.fit_before_convert(dataset)\r\n     69         dataset = self.convert_to_dataset(dataset)\r\n     70         self.fit(dataset)\r\n\r\n~/anaconda3/lib/python3.7/site-packages/autokeras/adapters/output_adapter.py in fit_before_convert(self, dataset)\r\n     65         if isinstance(dataset, tf.data.Dataset):\r\n     66             if not self.num_classes:\r\n---> 67                 shape = dataset.take(1).shape[1]\r\n     68                 if shape == 1:\r\n     69                     self.num_classes = 2\r\n\r\nAttributeError: 'TakeDataset' object has no attribute 'shape'\r\n```\r\n### Setup Details\r\nInclude the details about the versions of:\r\n - OS type and version:\r\n - Python: \r\n - autokeras: 1.0.1\r\n - scikit-learn:\r\n - numpy:\r\n - keras:\r\n - scipy:\r\n - tensorflow: 2.1.0\r\n - pytorch:\r\n\r\n### Additional context\r\n<!---\r\nAdd any other context about the problem here.\r\n-->\r\nTakeDataset doesn't have attribute 'shape', so the code may be wrong. You can also find I have set num_classes=10, so there are several bugs, not just one.\r\n\n", "before_files": [{"content": "import numpy as np\nimport pandas as pd\nimport tensorflow as tf\n\nfrom autokeras import encoders\nfrom autokeras.engine import adapter as adapter_module\n\n\nclass HeadAdapter(adapter_module.Adapter):\n\n    def __init__(self, name, **kwargs):\n        super().__init__(**kwargs)\n        self.name = name\n\n    def check(self, dataset):\n        supported_types = (tf.data.Dataset, np.ndarray, pd.DataFrame, pd.Series)\n        if not isinstance(dataset, supported_types):\n            raise TypeError('Expect the target data of {name} to be tf.data.Dataset,'\n                            ' np.ndarray, pd.DataFrame or pd.Series, but got {type}.'\n                            .format(name=self.name, type=type(dataset)))\n\n    def convert_to_dataset(self, dataset):\n        if isinstance(dataset, np.ndarray):\n            if len(dataset.shape) == 1:\n                dataset = dataset.reshape(-1, 1)\n        if isinstance(dataset, pd.DataFrame):\n            dataset = dataset.values\n        if isinstance(dataset, pd.Series):\n            dataset = dataset.values.reshape(-1, 1)\n        return super().convert_to_dataset(dataset)\n\n    def postprocess(self, y):\n        \"\"\"Postprocess the output of the Keras Model.\"\"\"\n        return y\n\n    def get_config(self):\n        config = super().get_config()\n        config.update({\n            'name': self.name,\n        })\n        return config\n\n\nclass ClassificationHeadAdapter(HeadAdapter):\n\n    def __init__(self, num_classes=None, **kwargs):\n        super().__init__(**kwargs)\n        self.num_classes = num_classes\n        self.label_encoder = None\n\n    def get_config(self):\n        config = super().get_config()\n        config.update({\n            'encoder': encoders.serialize(self.label_encoder),\n        })\n        return config\n\n    @classmethod\n    def from_config(cls, config):\n        obj = super().from_config(config)\n        obj.label_encoder = encoders.deserialize(config['encoder'])\n\n    def fit_before_convert(self, dataset):\n        # If in tf.data.Dataset, must be encoded already.\n        if isinstance(dataset, tf.data.Dataset):\n            if not self.num_classes:\n                shape = dataset.take(1).shape[1]\n                if shape == 1:\n                    self.num_classes = 2\n                else:\n                    self.num_classes = shape\n            return\n        if isinstance(dataset, pd.DataFrame):\n            dataset = dataset.values\n        if isinstance(dataset, pd.Series):\n            dataset = dataset.values.reshape(-1, 1)\n        # Not label.\n        if len(dataset.flatten()) != len(dataset):\n            self.num_classes = dataset.shape[1]\n            return\n        labels = set(dataset.flatten())\n        if self.num_classes is None:\n            self.num_classes = len(labels)\n        if self.num_classes == 2:\n            self.label_encoder = encoders.LabelEncoder()\n        elif self.num_classes > 2:\n            self.label_encoder = encoders.OneHotEncoder()\n        elif self.num_classes < 2:\n            raise ValueError('Expect the target data for {name} to have '\n                             'at least 2 classes, but got {num_classes}.'\n                             .format(name=self.name, num_classes=self.num_classes))\n        self.label_encoder.fit(dataset)\n\n    def convert_to_dataset(self, dataset):\n        if self.label_encoder:\n            dataset = self.label_encoder.encode(dataset)\n        return super().convert_to_dataset(dataset)\n\n    def postprocess(self, y):\n        if self.label_encoder:\n            y = self.label_encoder.decode(y)\n        return y\n\n\nclass RegressionHeadAdapter(HeadAdapter):\n    pass\n", "path": "autokeras/adapters/output_adapter.py"}], "after_files": [{"content": "import numpy as np\nimport pandas as pd\nimport tensorflow as tf\n\nfrom autokeras import encoders\nfrom autokeras import utils\nfrom autokeras.engine import adapter as adapter_module\n\n\nclass HeadAdapter(adapter_module.Adapter):\n\n    def __init__(self, name, **kwargs):\n        super().__init__(**kwargs)\n        self.name = name\n\n    def check(self, dataset):\n        supported_types = (tf.data.Dataset, np.ndarray, pd.DataFrame, pd.Series)\n        if not isinstance(dataset, supported_types):\n            raise TypeError('Expect the target data of {name} to be tf.data.Dataset,'\n                            ' np.ndarray, pd.DataFrame or pd.Series, but got {type}.'\n                            .format(name=self.name, type=type(dataset)))\n\n    def convert_to_dataset(self, dataset):\n        if isinstance(dataset, np.ndarray):\n            if len(dataset.shape) == 1:\n                dataset = dataset.reshape(-1, 1)\n        if isinstance(dataset, pd.DataFrame):\n            dataset = dataset.values\n        if isinstance(dataset, pd.Series):\n            dataset = dataset.values.reshape(-1, 1)\n        return super().convert_to_dataset(dataset)\n\n    def postprocess(self, y):\n        \"\"\"Postprocess the output of the Keras Model.\"\"\"\n        return y\n\n    def get_config(self):\n        config = super().get_config()\n        config.update({\n            'name': self.name,\n        })\n        return config\n\n\nclass ClassificationHeadAdapter(HeadAdapter):\n\n    def __init__(self, num_classes=None, **kwargs):\n        super().__init__(**kwargs)\n        self.num_classes = num_classes\n        self.label_encoder = None\n\n    def get_config(self):\n        config = super().get_config()\n        config.update({\n            'encoder': encoders.serialize(self.label_encoder),\n        })\n        return config\n\n    @classmethod\n    def from_config(cls, config):\n        obj = super().from_config(config)\n        obj.label_encoder = encoders.deserialize(config['encoder'])\n\n    def fit_before_convert(self, dataset):\n        # If in tf.data.Dataset, must be encoded already.\n        if isinstance(dataset, tf.data.Dataset):\n            if not self.num_classes:\n                shape = utils.dataset_shape(dataset)[0]\n                # Single column with 0s and 1s.\n                if shape == 1:\n                    self.num_classes = 2\n                else:\n                    self.num_classes = shape\n            return\n        if isinstance(dataset, pd.DataFrame):\n            dataset = dataset.values\n        if isinstance(dataset, pd.Series):\n            dataset = dataset.values.reshape(-1, 1)\n        # Not label.\n        if len(dataset.flatten()) != len(dataset):\n            self.num_classes = dataset.shape[1]\n            return\n        labels = set(dataset.flatten())\n        if self.num_classes is None:\n            self.num_classes = len(labels)\n        if self.num_classes == 2:\n            self.label_encoder = encoders.LabelEncoder()\n        elif self.num_classes > 2:\n            self.label_encoder = encoders.OneHotEncoder()\n        elif self.num_classes < 2:\n            raise ValueError('Expect the target data for {name} to have '\n                             'at least 2 classes, but got {num_classes}.'\n                             .format(name=self.name, num_classes=self.num_classes))\n        self.label_encoder.fit(dataset)\n\n    def convert_to_dataset(self, dataset):\n        if self.label_encoder:\n            dataset = self.label_encoder.encode(dataset)\n        return super().convert_to_dataset(dataset)\n\n    def postprocess(self, y):\n        if self.label_encoder:\n            y = self.label_encoder.decode(y)\n        return y\n\n\nclass RegressionHeadAdapter(HeadAdapter):\n    pass\n", "path": "autokeras/adapters/output_adapter.py"}]}