<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _policy_psets(policy_instances):
 """Find all permission sets making use of all of a list of policy_instances. The input is an array of policy instances. """

    if len(policy_instances) == 0:
        # Special case: find any permission sets that don't have
        # associated policy instances.
        return PermissionSet.objects.filter(policyinstance__isnull=True)
    else:
        return PermissionSet.objects.filter(
            policyinstance__policy__in=policy_instances).distinct()