def find_layer_in_model(model, layer_name):
    """
    Find a layer in a model by name
    """

    layer = None
    for lay in model.model.layers:
        if lay.name == layer_name:
            layer = lay
            break
    if not layer:
        raise ValueError(f"layer {layer_name} not found!")

    return layer