<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _infer_record_outputs(inputs, unlist, file_vs, std_vs, parallel, to_include=None, exclude=None):
 """Infer the outputs of a record from the original inputs """

    fields = []
    unlist = set([_get_string_vid(x) for x in unlist])
    input_vids = set([_get_string_vid(v) for v in _handle_special_inputs(inputs, file_vs)])
    to_include = set([_get_string_vid(x) for x in to_include]) if to_include else None
    to_exclude = tuple(set([_get_string_vid(x) for x in exclude])) if exclude else None
    added = set([])
    for raw_v in std_vs + [v for v in file_vs if get_base_id(v["id"]) in input_vids]:
        # unpack record inside this record and un-nested inputs to avoid double nested
        cur_record = is_cwl_record(raw_v)
        if cur_record:
            # unlist = unlist | set([field["name"] for field in cur_record["fields"]])
            nested_vs = [{"id": field["name"], "type": field["type"]} for field in cur_record["fields"]]
        else:
            nested_vs = [raw_v]
        for orig_v in nested_vs:
            if (get_base_id(orig_v["id"]) not in added
                 and (not to_include or get_base_id(orig_v["id"]) in to_include)):
                if to_exclude is None or not get_base_id(orig_v["id"]).startswith(to_exclude):
                    cur_v = {}
                    cur_v["name"] = get_base_id(orig_v["id"])
                    cur_v["type"] = orig_v["type"]
                    if cur_v["name"] in unlist:
                        cur_v = _flatten_nested_input(cur_v)
                    fields.append(_add_secondary_to_rec_field(orig_v, cur_v))
                    added.add(get_base_id(orig_v["id"]))
    return fields