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

def attach_volume(node_id, volume_id, profile, device=None, **libcloud_kwargs):
    '''
    Attaches volume to node.

    :param node_id:  Node ID to target
    :type  node_id: ``str``

    :param volume_id:  Volume ID from which to attach
    :type  volume_id: ``str``

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

    :param device: Where the device is exposed, e.g. '/dev/sdb'
    :type device: ``str``

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

    CLI Example:

    .. code-block:: bash

        salt myminion libcloud_compute.detach_volume vol1 profile1
    '''
    conn = _get_driver(profile=profile)
    libcloud_kwargs = salt.utils.args.clean_kwargs(**libcloud_kwargs)
    volume = _get_by_id(conn.list_volumes(), volume_id)
    node = _get_by_id(conn.list_nodes(), node_id)
    return conn.attach_volume(node, volume, device=device, **libcloud_kwargs)