<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def optimize_orientations(fwtour, clm, phase, cpus):
 """ Optimize the orientations of contigs by using heuristic flipping. """

    # Prepare input files
    tour_contigs = clm.active_contigs
    tour = clm.tour
    oo = clm.oo

    print_tour(fwtour, tour, "FLIPALL{}".format(phase),
               tour_contigs, oo, signs=clm.signs)
    tag1 = clm.flip_whole(tour)
    print_tour(fwtour, tour, "FLIPWHOLE{}".format(phase),
               tour_contigs, oo, signs=clm.signs)
    tag2 = clm.flip_one(tour)
    print_tour(fwtour, tour, "FLIPONE{}".format(phase),
               tour_contigs, oo, signs=clm.signs)

    return tag1, tag2