def trans(psy):
    """ Take the supplied psy object, apply OpenACC transformations
    to the schedule of invoke_0 and return the new psy object """
    from psyclone.transformations import ACCParallelTrans, ACCEnterDataTrans, ACCLoopTrans, ACCRoutineTrans
    ptrans = ACCParallelTrans()
    ltrans = ACCLoopTrans()
    dtrans = ACCEnterDataTrans()
    ktrans = ACCRoutineTrans()
    invoke = psy.invokes.get('invoke_0')
    schedule = invoke.schedule
    schedule.view()
    from psyclone.psyGen import Loop
    for child in schedule.children:
        if isinstance(child, Loop):
            newschedule, _ = ltrans.apply(child, {'collapse': 2})
            schedule = newschedule
    newschedule, _ = ptrans.apply(schedule.children)
    newschedule, _ = dtrans.apply(schedule)
    for kern in schedule.coded_kernels():
        _, _ = ktrans.apply(kern)
    invoke.schedule = newschedule
    newschedule.view()
    return psy
