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

def set_ntp_authentication(target=None,
                           authentication_type=None,
                           key_id=None,
                           authentication_key=None,
                           algorithm=None,
                           deploy=False):
    '''
    Set the NTP authentication of the Palo Alto proxy minion. A commit will be required before this is processed.

    CLI Example:

    Args:
        target(str): Determines the target of the authentication. Valid options are primary, secondary, or both.

        authentication_type(str): The authentication type to be used. Valid options are symmetric, autokey, and none.

        key_id(int): The NTP authentication key ID.

        authentication_key(str): The authentication key.

        algorithm(str): The algorithm type to be used for a symmetric key. Valid options are md5 and sha1.

        deploy (bool): If true then commit the full candidate configuration, if false only set pending change.

    .. code-block:: bash

        salt '*' ntp.set_authentication target=both authentication_type=autokey
        salt '*' ntp.set_authentication target=primary authentication_type=none
        salt '*' ntp.set_authentication target=both authentication_type=symmetric key_id=15 authentication_key=mykey algorithm=md5
        salt '*' ntp.set_authentication target=both authentication_type=symmetric key_id=15 authentication_key=mykey algorithm=md5 deploy=True

    '''
    ret = {}

    if target not in ['primary', 'secondary', 'both']:
        raise salt.exceptions.CommandExecutionError("Target option must be primary, secondary, or both.")

    if authentication_type not in ['symmetric', 'autokey', 'none']:
        raise salt.exceptions.CommandExecutionError("Type option must be symmetric, autokey, or both.")

    if authentication_type == "symmetric" and not authentication_key:
        raise salt.exceptions.CommandExecutionError("When using symmetric authentication, authentication_key must be "
                                                    "provided.")

    if authentication_type == "symmetric" and not key_id:
        raise salt.exceptions.CommandExecutionError("When using symmetric authentication, key_id must be provided.")

    if authentication_type == "symmetric" and algorithm not in ['md5', 'sha1']:
        raise salt.exceptions.CommandExecutionError("When using symmetric authentication, algorithm must be md5 or "
                                                    "sha1.")

    if authentication_type == 'symmetric':
        if target == 'primary' or target == 'both':
            query = {'type': 'config',
                     'action': 'set',
                     'xpath': '/config/devices/entry[@name=\'localhost.localdomain\']/deviceconfig/system/ntp-servers/'
                              'primary-ntp-server/authentication-type',
                     'element': '<symmetric-key><algorithm><{0}><authentication-key>{1}</authentication-key></{0}>'
                                '</algorithm><key-id>{2}</key-id></symmetric-key>'.format(algorithm,
                                                                                          authentication_key,
                                                                                          key_id)}
            ret.update({'primary_server': __proxy__['panos.call'](query)})

        if target == 'secondary' or target == 'both':
            query = {'type': 'config',
                     'action': 'set',
                     'xpath': '/config/devices/entry[@name=\'localhost.localdomain\']/deviceconfig/system/ntp-servers/'
                              'secondary-ntp-server/authentication-type',
                     'element': '<symmetric-key><algorithm><{0}><authentication-key>{1}</authentication-key></{0}>'
                                '</algorithm><key-id>{2}</key-id></symmetric-key>'.format(algorithm,
                                                                                          authentication_key,
                                                                                          key_id)}
            ret.update({'secondary_server': __proxy__['panos.call'](query)})
    elif authentication_type == 'autokey':
        if target == 'primary' or target == 'both':
            query = {'type': 'config',
                     'action': 'set',
                     'xpath': '/config/devices/entry[@name=\'localhost.localdomain\']/deviceconfig/system/ntp-servers/'
                              'primary-ntp-server/authentication-type',
                     'element': '<autokey/>'}
            ret.update({'primary_server': __proxy__['panos.call'](query)})

        if target == 'secondary' or target == 'both':
            query = {'type': 'config',
                     'action': 'set',
                     'xpath': '/config/devices/entry[@name=\'localhost.localdomain\']/deviceconfig/system/ntp-servers/'
                              'secondary-ntp-server/authentication-type',
                     'element': '<autokey/>'}
            ret.update({'secondary_server': __proxy__['panos.call'](query)})
    elif authentication_type == 'none':
        if target == 'primary' or target == 'both':
            query = {'type': 'config',
                     'action': 'set',
                     'xpath': '/config/devices/entry[@name=\'localhost.localdomain\']/deviceconfig/system/ntp-servers/'
                              'primary-ntp-server/authentication-type',
                     'element': '<none/>'}
            ret.update({'primary_server': __proxy__['panos.call'](query)})

        if target == 'secondary' or target == 'both':
            query = {'type': 'config',
                     'action': 'set',
                     'xpath': '/config/devices/entry[@name=\'localhost.localdomain\']/deviceconfig/system/ntp-servers/'
                              'secondary-ntp-server/authentication-type',
                     'element': '<none/>'}
            ret.update({'secondary_server': __proxy__['panos.call'](query)})

    if deploy is True:
        ret.update(commit())

    return ret