def inverse_datum_def(datum_def: list):
    """
    Reverse the order of the datum definition list and prepend 'inv' to each
    layer.

    Parameters
    ----------
    datum_def
        A list describing the layers of a datum definition.

    Returns
    -------
    list
        The provided list reversed with 'inv' prepended to each layer.

    """
    inverse = []
    for layer in datum_def[::-1]:
        if '+inv' in layer:
            nlayer = layer.replace('+inv ', '')
            inverse.append(nlayer)
        else:
            inverse.append(' '.join(['+inv', layer]))
    return inverse