def _augment_polygons_as_keypoints(self, polygons_on_images, random_state,<EOL>parents, hooks, recoverer=None):
kps_ois = []<EOL>kp_counts = []<EOL>for polys_oi in polygons_on_images:<EOL><INDENT>kps = []<EOL>kp_counts_image = []<EOL>for poly in polys_oi.polygons:<EOL><INDENT>poly_kps = poly.to_keypoints()<EOL>kps.extend(poly_kps)<EOL>kp_counts_image.append(len(poly_kps))<EOL><DEDENT>kps_ois.append(ia.KeypointsOnImage(kps, shape=polys_oi.shape))<EOL>kp_counts.append(kp_counts_image)<EOL><DEDENT>kps_ois_aug = self._augment_keypoints(kps_ois, random_state, parents, hooks)<EOL>result = []<EOL>gen = enumerate(zip(kps_ois_aug, kp_counts))<EOL>for img_idx, (kps_oi_aug, kp_counts_image) in gen:<EOL><INDENT>polys_aug = []<EOL>counter = <NUM_LIT:0><EOL>for i, count in enumerate(kp_counts_image):<EOL><INDENT>poly_kps_aug = kps_oi_aug.keypoints[counter:counter+count]<EOL>poly_old = polygons_on_images[img_idx].polygons[i]<EOL>if recoverer is not None:<EOL><INDENT>poly_aug = recoverer.recover_from(<EOL>[(kp.x, kp.y) for kp in poly_kps_aug],<EOL>poly_old,<EOL>random_state=random_state)<EOL><DEDENT>else:<EOL><INDENT>poly_aug = poly_old.deepcopy(exterior=poly_kps_aug)<EOL><DEDENT>polys_aug.append(poly_aug)<EOL>counter += count<EOL><DEDENT>result.append(ia.PolygonsOnImage(polys_aug, shape=kps_oi_aug.shape))<EOL><DEDENT>return result<EOL>
Augment polygons by applying keypoint augmentation to their vertices.

Parameters
----------
polygons_on_images : list of imgaug.PolygonsOnImage
    Polygons to augment. They may be changed in-place.

random_state : numpy.random.RandomState
    The random state to use for all sampling tasks during the
    augmentation.

parents : list of imgaug.augmenters.meta.Augmenter
    See :func:`imgaug.augmenters.meta.Augmenter.augment_polygons`.

hooks : imgaug.HooksKeypoints or None
    See :func:`imgaug.augmenters.meta.Augmenter.augment_polygons`.

recoverer : None or imgaug._ConcavePolygonRecoverer
    An instance used to repair invalid polygons after augmentation.
    Must offer the method
    ``recover_from(new_exterior, old_polygon, random_state=0)``.
    If ``None`` then invalid polygons are not repaired.

Returns
----------
list of imgaug.PolygonsOnImage
    The augmented polygons.