<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def delete_entity(sender, instance, **kwargs):
 """Delete Entity when last Data object is deleted."""

    # 1 means that the last Data object is going to be deleted.
    Entity.objects.annotate(num_data=Count('data')).filter(data=instance, num_data=1).delete()