# Buggy code
def get_config(self):
    blocks = [serialize(block) for block in self.blocks]
    nodes = {str(self._node_to_id[node]): serialize(node) for node in self.inputs}
    override_hps = [
        tf.keras.utils.serialize_keras_object(hp) for hp in self.override_hps
    ]
    block_inputs = {
        str(block_id): [self._node_to_id[node] for node in block.inputs]
        for block_id, block in enumerate(self.blocks)
    }
    block_outputs = {
        str(block_id): [self._node_to_id[node] for node in block.outputs]
        for block_id, block in enumerate(self.blocks)
    }

    outputs = [self._node_to_id[node] for node in self.outputs]

    return {
        "override_hps": override_hps,  # List [serialized].
        "blocks": blocks,  # Dict {id: serialized}.
        "nodes": nodes,  # Dict {id: serialized}.
        "outputs": outputs,  # List of node_ids.
        "block_inputs": block_inputs,  # Dict {id: List of node_ids}.
        "block_outputs": block_outputs,  # Dict {id: List of node_ids}.
    }


# Traceback (TypeError)
Traceback (most recent call last):
File "mnist_model.py", line 12, in <module>
clf = ak.ImageClassifier(metrics=['accuracy', custom_metric], max_trials=3)
File "/home/lhs18285/miniconda3/envs/nas/lib/python3.7/site-packages/autokeras/tasks/image.py", line 67, in __init__
seed=seed)
File "/home/lhs18285/miniconda3/envs/nas/lib/python3.7/site-packages/autokeras/tasks/image.py", line 19, in __init__
**kwargs)
File "/home/lhs18285/miniconda3/envs/nas/lib/python3.7/site-packages/autokeras/auto_model.py", line 125, in __init__
project_name=name)
File "/home/lhs18285/miniconda3/envs/nas/lib/python3.7/site-packages/autokeras/tuners/task_specific.py", line 66, in __init__
**kwargs)
File "/home/lhs18285/miniconda3/envs/nas/lib/python3.7/site-packages/autokeras/tuners/greedy.py", line 197, in __init__
**kwargs)
File "/home/lhs18285/miniconda3/envs/nas/lib/python3.7/site-packages/autokeras/engine/tuner.py", line 35, in __init__
graph_module.serialize(self.hypermodel.hypermodel))
File "/home/lhs18285/miniconda3/envs/nas/lib/python3.7/site-packages/autokeras/utils.py", line 179, in save_json
obj = json.dumps(obj)
File "/home/lhs18285/miniconda3/envs/nas/lib/python3.7/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/home/lhs18285/miniconda3/envs/nas/lib/python3.7/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/home/lhs18285/miniconda3/envs/nas/lib/python3.7/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/home/lhs18285/miniconda3/envs/nas/lib/python3.7/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type function is not JSON serializable

# Fixed code
def get_config(self):
    blocks = [hypermodels.serialize(block) for block in self.blocks]
    nodes = {
        str(self._node_to_id[node]): nodes_module.serialize(node)
        for node in self.inputs
    }
    override_hps = [
        kerastuner.engine.hyperparameters.serialize(hp) for hp in self.override_hps
    ]
    block_inputs = {
        str(block_id): [self._node_to_id[node] for node in block.inputs]
        for block_id, block in enumerate(self.blocks)
    }
    block_outputs = {
        str(block_id): [self._node_to_id[node] for node in block.outputs]
        for block_id, block in enumerate(self.blocks)
    }

    outputs = [self._node_to_id[node] for node in self.outputs]

    return {
        "override_hps": override_hps,  # List [serialized].
        "blocks": blocks,  # Dict {id: serialized}.
        "nodes": nodes,  # Dict {id: serialized}.
        "outputs": outputs,  # List of node_ids.
        "block_inputs": block_inputs,  # Dict {id: List of node_ids}.
        "block_outputs": block_outputs,  # Dict {id: List of node_ids}.
    }