'Args:
ds (DataFlow): input DataFlow.
augmentors (AugmentorList): a list of :class:`imgaug.ImageAugmentor` instance to be applied in order.
index: tuple of indices of components.
copy (bool): Some augmentors modify the input images. When copy is
True, a copy will be made before any augmentors are applied,
to keep the original images not modified.
Turn it off to save time when you know it\'s OK.'

def __init__(self, ds, augmentors, index=(0, 1), copy=True):

    if isinstance(augmentors, AugmentorList):
        self.augs = augmentors
    else:
        self.augs = AugmentorList(augmentors)
    self.ds = ds
    self._nr_error = 0
    def func(dp):
        dp = copy_mod.copy(dp)
        copy_func = (copy_mod.deepcopy if copy else (lambda x: x))
        try:
            im = copy_func(dp[index[0]])
            (im, prms) = self.augs._augment_return_params(im)
            dp[index[0]] = im
            for idx in index[1:]:
                dp[idx] = self.augs._augment(copy_func(dp[idx]), prms)
            return dp
        except KeyboardInterrupt:
            raise
        except Exception:
            self._nr_error += 1
            if (((self._nr_error % 1000) == 0) or (self._nr_error < 10)):
                logger.exception('Got    {}    augmentation    errors.'.format(self._nr_error))
            return None
    super(AugmentImageComponents, self).__init__(ds, func)
