<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def listener_dict_to_tuple(listener):
    '''
    Convert an ELB listener dict into a listener tuple used by certain parts of
    the AWS ELB API.

    CLI example:

    .. code-block:: bash

        salt myminion boto_elb.listener_dict_to_tuple '{"elb_port":80,"instance_port":80,"elb_protocol":"HTTP"}'
    '''
    # We define all listeners as complex listeners.
    if 'instance_protocol' not in listener:
        instance_protocol = listener['elb_protocol'].upper()
    else:
        instance_protocol = listener['instance_protocol'].upper()
    listener_tuple = [listener['elb_port'], listener['instance_port'],
                      listener['elb_protocol'], instance_protocol]
    if 'certificate' in listener:
        listener_tuple.append(listener['certificate'])
    return tuple(listener_tuple)