<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _merge_wf_inputs(new, out, wf_outputs, to_ignore, parallel, nested_inputs):
 """Merge inputs for a sub-workflow, adding any not present inputs in out. Skips inputs that are internally generated or generated and ignored, keeping only as inputs those that we do not generate internally. """

    internal_generated_ids = []
    for vignore in to_ignore:
        vignore_id = _get_string_vid(vignore)
        # ignore anything we generate internally, but not those we need to pull in
        # from the external process
        if vignore_id not in [v["id"] for v in wf_outputs]:
            internal_generated_ids.append(vignore_id)
    ignore_ids = set(internal_generated_ids + [v["id"] for v in wf_outputs])
    cur_ids = set([v["id"] for v in out])
    remapped_new = []
    for v in new:
        remapped_v = copy.deepcopy(v)
        outv = copy.deepcopy(v)
        outv["id"] = get_base_id(v["id"])
        outv["source"] = v["id"]
        if outv["id"] not in cur_ids and outv["id"] not in ignore_ids:
            if nested_inputs and v["id"] in nested_inputs:
                outv = _flatten_nested_input(outv)
            out.append(outv)
        if remapped_v["id"] in set([v["source"] for v in out]):
            remapped_v["source"] = get_base_id(remapped_v["id"])
        remapped_new.append(remapped_v)
    return out, remapped_new