<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _drain(writer, ion_event):
 """Drain the writer of its pending write events. Args: writer (Coroutine):
 A writer co-routine. ion_event (amazon.ion.core.IonEvent):
 The first event to apply to the writer. Yields: DataEvent: Yields each pending data event. """

    result_event = _WRITE_EVENT_HAS_PENDING_EMPTY
    while result_event.type is WriteEventType.HAS_PENDING:
        result_event = writer.send(ion_event)
        ion_event = None
        yield result_event