def create_names(instances, Ns, str_format):
    """
    Create a list of names for spectra loaded from task instances.

    :param instances:
        A list of task instances where spectra were loaded. This should
        be length `N` long.
    
    :param Ns:
        A list containing the number of spectra loaded from each task instance.
        This should have the same length as `instances`.
    
    :param str_format:
        A string formatting for the names. The available keywords include
        all parameters associated with the task, as well as the `star_index`
        and the `spectrum_index`.
    
    :returns:
        A list with length `sum(Ns)` that contains the given names for all 
        the spectra loaded.
    """
    names = []
    for star_index, (instance, N) in enumerate(zip(instances, Ns)):
        kwds = instance.parameters.copy()
        kwds.update(star_index=star_index)
        for index in range(N):
            kwds["spectrum_index"] = index
            names.append(str_format.format(**kwds))
    return names