<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def phase_parents_by_transmission(g, window_size):
 """Phase parent genotypes from a trio or cross, given progeny genotypes already phased by Mendelian transmission. Parameters g : GenotypeArray Genotype array, with parents as first two columns and progeny as remaining columns, where progeny genotypes are already phased. window_size : int Number of previous heterozygous sites to include when phasing each parent. A number somewhere between 10 and 100 may be appropriate, depending on levels of heterozygosity and quality of data. Returns ------- g : GenotypeArray Genotype array with parents phased where possible. """


    # setup
    check_type(g, GenotypeArray)
    check_dtype(g.values, 'i1')
    check_ploidy(g.ploidy, 2)
    if g.is_phased is None:
        raise ValueError('genotype array must first have progeny phased by transmission')
    check_min_samples(g.n_samples, 3)

    # run the phasing
    g._values = memoryview_safe(g.values)
    g._is_phased = memoryview_safe(g.is_phased)
    _opt_phase_parents_by_transmission(g.values, g.is_phased.view('u1'), window_size)

    # outputs
    return g