<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def select_executor(elem, doc):
 """Determines the executor for the code in `elem.text`. The elem attributes and classes select the executor in this order (highest to lowest):
 - first element class (.class) determines language and thus executor Args: elem The AST element. doc The document. Returns: The command to execute code. """

    executor = EXECUTORS['default']

    if 'cmd' in elem.attributes.keys():
        executor = elem.attributes['cmd']
    elif 'runas' in elem.attributes.keys():
        executor = EXECUTORS[elem.attributes['runas']]
    elif elem.classes[0] != 'exec':
        executor = EXECUTORS[elem.classes[0]]

    return executor