def METHOD_NAME(self, template_ids):
    label_ids = self.filter(template_id__in=template_ids).distinct().values_list("label_id", flat=True)
    labels = Label.objects.filter(id__in=label_ids).values_list("id", "name", "color")
    return labels