import click


def validate_layers(ctx, param, value):
    """Validates that the input layers passed into CLI are correctly formatted."""
    try:
        layers = [l for l in value.split(',')]
        convs = [(int(p),int(l)) for p,l in [layer.split("_") for layer in layers]]
        assert all(isinstance(l, int) and isinstance(p, int) for p,l in convs)
        return [f'conv{l}' for l in layers]
    except ValueError:
        raise click.BadParameter('Layers need to be ints seperated by commas')