import collections


def _name_regions(regions, vertex_slice):
    """Convert a list of regions into the correct form for a method expecting
    two dictionaries describing the regions.
    """
    regions = collections.OrderedDict({
        i: r for i, r in enumerate(regions, start=1) if r is not None
    })
    region_args = collections.defaultdict(
        lambda: ((vertex_slice, ), {})
    )

    return regions, region_args