<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _normalize(in_file, data, passonly=False, normalize_indels=True, split_biallelic=True, remove_oldeffects=False, nonrefonly=False, work_dir=None):
 """Convert multi-allelic variants into single allelic. `vt normalize` has the -n flag passed (skipping reference checks) because of errors where the reference genome has non GATCN ambiguous bases. These are not supported in VCF, so you'll have a mismatch of N in VCF versus R (or other ambiguous bases) in the genome. """

    if remove_oldeffects:
        out_file = "%s-noeff-decompose%s" % utils.splitext_plus(in_file)
        old_effects = [a for a in ["CSQ", "ANN"] if a in cyvcf2.VCF(in_file)]
        if old_effects:
            clean_effects_cmd = " | bcftools annotate -x %s " % (",".join(["INFO/%s" % x for x in old_effects]))
        else:
            clean_effects_cmd = ""
    else:
        clean_effects_cmd = ""
        out_file = "%s-decompose%s" % utils.splitext_plus(in_file)
    if passonly or nonrefonly:
        subset_vcf_cmd = " | bcftools view "
        if passonly:
            subset_vcf_cmd += "-f 'PASS,.' "
        if nonrefonly:
            subset_vcf_cmd += "--min-ac 1:nref "
    else:
        subset_vcf_cmd = ""
    if work_dir:
        out_file = os.path.join(work_dir, os.path.basename(out_file))
    if not utils.file_exists(out_file):
        ref_file = dd.get_ref_file(data)
        assert out_file.endswith(".vcf.gz")
        with file_transaction(data, out_file) as tx_out_file:
            cmd = ("gunzip -c " + in_file +
                   subset_vcf_cmd + clean_effects_cmd +
                   (" | vcfallelicprimitives -t DECOMPOSED --keep-geno" if split_biallelic else "") +
                   " | sed 's/ID=AD,Number=./ID=AD,Number=R/'" +
                   " | vt decompose -s - " +
                   ((" | vt normalize -n -r " + ref_file + " - ") if normalize_indels else "") +
                   " | awk '{ gsub(\"./-65\", \"./.\"); print $0 }'" +
                   " | sed -e 's/Number=A/Number=1/g'" +
                   " | bgzip -c > " + tx_out_file
                   )
            do.run(cmd, "Multi-allelic to single allele")
    return vcfutils.bgzip_and_index(out_file, data["config"])