import torch


def lower_matrix_to_vector(lower: torch.Tensor) -> torch.Tensor:
    """Convert a lower triangular matrix to a vector.

    Parameters
    ----------
    lower : torch.Tensor
        lower

    Returns
    -------
    torch.Tensor

    """
    shape = lower.shape
    assert shape[-1] == shape[-2]
    lower_idx = torch.tril_indices(shape[-1], shape[-1])
    lower_flat = lower[..., lower_idx[0], lower_idx[1]]
    return lower_flat