def cluster_grasps(grasps, qualities):
            cluster_indexes = np.asarray(
                utils.farthest_points(grasps, num_clusters,
                                      utils.distance_by_translation_grasp))
            output_grasps = []
            output_qualities = []

            for i in range(num_clusters):
                indexes = np.where(cluster_indexes == i)[0]
                if ratio_of_grasps_to_be_used < 1:
                    num_grasps_to_choose = max(
                        1,
                        int(ratio_of_grasps_to_be_used * float(len(indexes))))
                    if len(indexes) == 0:
                        raise NoPositiveGraspsException
                    indexes = np.random.choice(indexes,
                                               size=num_grasps_to_choose,
                                               replace=False)

                output_grasps.append(grasps[indexes, :, :])
                output_qualities.append(qualities[indexes])

            output_grasps = np.asarray(output_grasps)
            output_qualities = np.asarray(output_qualities)

            return output_grasps, output_qualities
    def apply_dropout(self, pc):
        if self.opt.occlusion_nclusters == 0 or self.opt.occlusion_dropout_rate == 0.:
            return np.copy(pc)

        labels = utils.farthest_points(pc, self.opt.occlusion_nclusters,
                                       utils.distance_by_translation_point)

        removed_labels = np.unique(labels)
        removed_labels = removed_labels[np.random.rand(removed_labels.shape[0])
                                        < self.opt.occlusion_dropout_rate]
        if removed_labels.shape[0] == 0:
            return np.copy(pc)
        mask = np.ones(labels.shape, labels.dtype)
        for l in removed_labels:
            mask = np.logical_and(mask, labels != l)
        return pc[mask]