def augment_segmentation_maps(self, segmaps, parents=None, hooks=None):
input_was_single_instance = False<EOL>if isinstance(segmaps, ia.SegmentationMapOnImage):<EOL><INDENT>input_was_single_instance = True<EOL>segmaps = [segmaps]<EOL><DEDENT>heatmaps_with_nonempty = [segmap.to_heatmaps(only_nonempty=True, not_none_if_no_nonempty=True)<EOL>for segmap in segmaps]<EOL>heatmaps = [heatmaps_i for heatmaps_i, nonempty_class_indices_i in heatmaps_with_nonempty]<EOL>nonempty_class_indices = [nonempty_class_indices_i<EOL>for heatmaps_i, nonempty_class_indices_i in heatmaps_with_nonempty]<EOL>heatmaps_aug = self.augment_heatmaps(heatmaps, parents=parents, hooks=hooks)<EOL>segmaps_aug = []<EOL>for segmap, heatmaps_aug_i, nonempty_class_indices_i in zip(segmaps, heatmaps_aug, nonempty_class_indices):<EOL><INDENT>segmap_aug = ia.SegmentationMapOnImage.from_heatmaps(heatmaps_aug_i,<EOL>class_indices=nonempty_class_indices_i,<EOL>nb_classes=segmap.nb_classes)<EOL>segmap_aug.input_was = segmap.input_was<EOL>segmaps_aug.append(segmap_aug)<EOL><DEDENT>if input_was_single_instance:<EOL><INDENT>return segmaps_aug[<NUM_LIT:0>]<EOL><DEDENT>return segmaps_aug<EOL>
Augment segmentation maps.

Parameters
----------
segmaps : imgaug.SegmentationMapOnImage or \
          list of imgaug.SegmentationMapOnImage
    Segmentation map(s) to augment. Either a single heatmap or a list of
    segmentation maps.

parents : None or list of imgaug.augmenters.meta.Augmenter, optional
    Parent augmenters that have previously been called before the
    call to this function. Usually you can leave this parameter as None.
    It is set automatically for child augmenters.

hooks : None or imgaug.HooksHeatmaps, optional
    HooksHeatmaps object to dynamically interfere with the augmentation process.

Returns
-------
segmaps_aug : imgaug.SegmentationMapOnImage or \
              list of imgaug.SegmentationMapOnImage
    Corresponding augmented segmentation map(s).