def _search_layer_backwards(model, condition):
    """
    Search for a layer in ``model``, backwards (starting from the output layer),
    checking if the layer is suitable with the callable ``condition``,
    """
    for layer in model.layers[::-1]:
        if condition(model, layer):
            return layer
    raise ValueError('Could not find a suitable target layer automatically.')
