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

def import_key_pair(name, key, profile, key_type=None, **libcloud_kwargs):
    '''
    Import a new public key from string or a file path

    :param name: Key pair name.
    :type name: ``str``

    :param key: Public key material, the string or a path to a file
    :type  key: ``str`` or path ``str``

    :param profile: The profile key
    :type  profile: ``str``

    :param key_type: The key pair type, either `FILE` or `STRING`. Will detect if not provided
        and assume that if the string is a path to an existing path it is a FILE, else STRING.
    :type  key_type: ``str``

    :param libcloud_kwargs: Extra arguments for the driver's import_key_pair_from_xxx method
    :type  libcloud_kwargs: ``dict``

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.import_key_pair pair1 key_value_data123 profile1
        salt myminion libcloud_compute.import_key_pair pair1 /path/to/key profile1
    '''
    conn = _get_driver(profile=profile)
    libcloud_kwargs = salt.utils.args.clean_kwargs(**libcloud_kwargs)
    if os.path.exists(key) or key_type == 'FILE':
        return _simple_key_pair(conn.import_key_pair_from_file(name,
                                                               key,
                                                               **libcloud_kwargs))
    else:
        return _simple_key_pair(conn.import_key_pair_from_string(name,
                                                                 key,
                                                                 **libcloud_kwargs))