def padding_rows(length, layers=6):
    """
    Calculate the number of padding rows for an input sequence matrix.

    Calculate the number of padding rows required by Sequence UNET for an input sequence matrix. This number of 0 rows should be added to the end of the array so it can be evenly halved a sufficient number of times.

    Parameters
    ----------
    length : int
        Sequence length
    layers : int
        Number of layers in the Sequence UNET model. All pre-trained models have 6 layers.

    Returns
    -------
    int
        Number of padding rows required.
    """
    return 2 ** (layers - 1) - length % 2 ** (layers - 1) if layers > 0 else 0