def METHOD_NAME(module, backup_client):
    result = {"changed": False}
    resource = module.params.get("resource")
    tags = module.params.get("tags")
    state = module.params.get("state")
    purge_tags = module.params.get("purge_tags")
    current_tags = get_backup_resource_tags(module, backup_client, resource)
    tags_to_add, tags_to_remove = compare_aws_tags(current_tags, tags, purge_tags=purge_tags)
    remove_tags = {}
    if state == "absent":
        for key in tags:
            if purge_tags is False and key in current_tags and (tags[key] is None or current_tags[key] == tags[key]):
                remove_tags[key] = current_tags[key]
        for key in tags_to_remove:
            remove_tags[key] = current_tags[key]
        if remove_tags:
            result["changed"] = True
            result["removed_tags"] = remove_tags
            if not module.check_mode:
                try:
                    backup_client.untag_resource(ResourceArn=resource, TagKeyList=list(remove_tags.keys()))
                except (BotoCoreError, ClientError) as remove_tag_error:
                    module.fail_json_aws(
                        remove_tag_error,
                        msg=f"Failed to remove tags {remove_tags} from resource {resource}",
                    )
    if state == "present" and tags_to_add:
        result["changed"] = True
        result["added_tags"] = tags_to_add
        if not module.check_mode:
            try:
                backup_client.tag_resource(ResourceArn=resource, Tags=tags_to_add)
            except (BotoCoreError, ClientError) as set_tag_error:
                module.fail_json_aws(set_tag_error, msg=f"Failed to set tags {tags_to_add} on resource {resource}")
    result["tags"] = get_backup_resource_tags(module, backup_client, resource)
    return result