<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def keras_model_to_graph_def(keras_layer):
 """Returns a GraphDef representation of the Keras model in a dict form. Note that it only supports models that implemented to_json(). Args: keras_layer: A dict from Keras model.to_json(). Returns: A GraphDef representation of the layers in the model. """

  input_to_layer = {}
  model_name_to_output = {}
  g = GraphDef()

  # Sequential model layers do not have a field "inbound_nodes" but
  # instead are defined implicitly via order of layers.
  prev_node_name = None

  for (name_scope, layer) in _walk_layers(keras_layer):
    if _is_model(layer):
      (input_to_layer, model_name_to_output, prev_node_name) = _update_dicts(
          name_scope, layer, input_to_layer, model_name_to_output, prev_node_name)
      continue

    layer_config = layer.get('config')
    node_name = _scoped_name(name_scope, layer_config.get('name'))

    node_def = g.node.add()
    node_def.name = node_name

    if layer.get('class_name') is not None:
      keras_cls_name = layer.get('class_name').encode('ascii')
      node_def.attr['keras_class'].s = keras_cls_name

    if layer_config.get('dtype') is not None:
      tf_dtype = dtypes.as_dtype(layer_config.get('dtype'))
      node_def.attr['dtype'].type = tf_dtype.as_datatype_enum

    if layer.get('inbound_nodes') is not None:
      for maybe_inbound_node in layer.get('inbound_nodes'):
        inbound_nodes = _norm_to_list_of_layers(maybe_inbound_node)
        for [name, size, index, _] in inbound_nodes:
          inbound_name = _scoped_name(name_scope, name)
          # An input to a layer can be output from a model. In that case, the name
          # of inbound_nodes to a layer is a name of a model. Remap the name of the
          # model to output layer of the model. Also, since there can be multiple
          # outputs in a model, make sure we pick the right output_layer from the model.
          inbound_node_names = model_name_to_output.get(
              inbound_name, [inbound_name])
          node_def.input.append(inbound_node_names[index])
    elif prev_node_name is not None:
      node_def.input.append(prev_node_name)

    if node_name in input_to_layer:
      node_def.input.append(input_to_layer.get(node_name))

    prev_node_name = node_def.name

  return g