def METHOD_NAME(collection, version, metadata):
    """Update tags at collection-level, only if highest version."""
    if collection.latest_version != version:
        return
    tags_not_in_db = [
        {'name': tag, 'description': tag, 'active': True}
        for tag in metadata['tags']
        if models.Tag.objects.filter(name=tag).count() == 0]
    models.Tag.objects.bulk_create([models.Tag(**t) for t in tags_not_in_db])
    tags_qs = models.Tag.objects.filter(name__in=metadata['tags'])
    collection.tags.add(*tags_qs)
    tags_not_in_metadata = [
        tag for tag in collection.tags.all()
        if tag.name not in metadata['tags']
    ]
    collection.tags.remove(*tags_not_in_metadata)