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

def tag_resource(region=None, key=None, keyid=None, profile=None, **kwargs):
    '''
    Add tags to a CloudFront resource.

    Resource
        The ARN of the affected CloudFront resource.

    Tags
        Dict of {'Tag': 'Value', ...} providing the tags to be set.

    region
        Region to connect to.

    key
        Secret key to use.

    keyid
        Access key to use.

    profile
        Dict, or pillar key pointing to a dict, containing AWS region/key/keyid.

    CLI Example:

    .. code-block:: bash

        salt myminion boto_cloudfront.tag_resource Tags='{Owner: Infra, Role: salt_master}' \\
                Resource='arn:aws:cloudfront::012345678012:distribution/ETLNABCDEF123'

    '''
    retries = 10
    sleep = 6
    kwargs = {k: v for k, v in kwargs.items() if not k.startswith('_')}
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    kwargs['Tags'] = {'Items': [{'Key': k, 'Value': v} for k, v in kwargs.get('Tags', {}).items()]}
    while retries:
        try:
            log.debug('Adding tags (%s) to CloudFront resource `%s`.', kwargs['Tags'],
                    kwargs.get('Resource'))
            conn.tag_resource(**kwargs)
            return True
        except botocore.exceptions.ParamValidationError as err:
            raise SaltInvocationError(str(err))
        except botocore.exceptions.ClientError as err:
            if retries and err.response.get('Error', {}).get('Code') == 'Throttling':
                retries -= 1
                log.debug('Throttled by AWS API, retrying in %s seconds...', sleep)
                time.sleep(sleep)
                continue
            log.error('Failed to add tags to resource `%s`:  %s', kwargs.get('Resource'),
                    err.message)
            return False