def find_layer_idx(model, layer_name):
layer_idx = None<EOL>for idx, layer in enumerate(model.layers):<EOL><INDENT>if layer.name == layer_name:<EOL><INDENT>layer_idx = idx<EOL>break<EOL><DEDENT><DEDENT>if layer_idx is None:<EOL><INDENT>raise ValueError("<STR_LIT>".format(layer_name))<EOL><DEDENT>return layer_idx<EOL>
Looks up the layer index corresponding to `layer_name` from `model`.

    Args:
        model: The `keras.models.Model` instance.
        layer_name: The name of the layer to lookup.

    Returns:
        The layer index if found. Raises an exception otherwise.