r"""
    Flattens `unflat_list` but remember how to reconstruct the `unflat_list`
    Returns `flat_list` and the `reverse_list` with indexes into the
    `flat_list`

    Args:
        unflat_list (list): list of nested lists that we will flatten.

    Returns:
        tuple : (flat_list, reverse_list)

    CommandLine:
        python -m utool.util_list --exec-invertible_flatten1 --show

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_list import *  # NOQA
        >>> import utool as ut
        >>> unflat_list = [[1, 2, 3], [4, 5], [6, 6]]
        >>> flat_list, reverse_list = invertible_flatten1(unflat_list)
        >>> result = ('flat_list = %s\n' % (ut.repr2(flat_list),))
        >>> result += ('reverse_list = %s' % (ut.repr2(reverse_list),))
        >>> print(result)
        flat_list = [1, 2, 3, 4, 5, 6, 6]
        reverse_list = [[0, 1, 2], [3, 4], [5, 6]]

def invertible_flatten1(unflat_list):
    r"""
    Flattens `unflat_list` but remember how to reconstruct the `unflat_list`
    Returns `flat_list` and the `reverse_list` with indexes into the
    `flat_list`

    Args:
        unflat_list (list): list of nested lists that we will flatten.

    Returns:
        tuple : (flat_list, reverse_list)

    CommandLine:
        python -m utool.util_list --exec-invertible_flatten1 --show

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_list import *  # NOQA
        >>> import utool as ut
        >>> unflat_list = [[1, 2, 3], [4, 5], [6, 6]]
        >>> flat_list, reverse_list = invertible_flatten1(unflat_list)
        >>> result = ('flat_list = %s\n' % (ut.repr2(flat_list),))
        >>> result += ('reverse_list = %s' % (ut.repr2(reverse_list),))
        >>> print(result)
        flat_list = [1, 2, 3, 4, 5, 6, 6]
        reverse_list = [[0, 1, 2], [3, 4], [5, 6]]
    """
    nextnum = functools.partial(six.next, itertools.count(0))
    # Build an unflat list of flat indexes
    reverse_list = [[nextnum() for _ in tup] for tup in unflat_list]
    flat_list = flatten(unflat_list)
    return flat_list, reverse_list