Generate adversarial images in a for loop.
    :param y: An array of shape (n, nb_classes) for true labels.
    :param y_target:  An array of shape (n, nb_classes) for target labels.
    Required for targeted attack.
    :param image_target: An array of shape (n, **image shape) for initial
    target images. Required for targeted attack.

    See parse_params for other kwargs.

def generate_np(self, x, **kwargs):
    """
    Generate adversarial images in a for loop.
    :param y: An array of shape (n, nb_classes) for true labels.
    :param y_target:  An array of shape (n, nb_classes) for target labels.
    Required for targeted attack.
    :param image_target: An array of shape (n, **image shape) for initial
    target images. Required for targeted attack.

    See parse_params for other kwargs.

    """

    x_adv = []

    if 'image_target' in kwargs and kwargs['image_target'] is not None:
      image_target = np.copy(kwargs['image_target'])
    else:
      image_target = None
    if 'y_target' in kwargs and kwargs['y_target'] is not None:
      y_target = np.copy(kwargs['y_target'])
    else:
      y_target = None

    for i, x_single in enumerate(x):
      img = np.expand_dims(x_single, axis=0)
      if image_target is not None:
        single_img_target = np.expand_dims(image_target[i], axis=0)
        kwargs['image_target'] = single_img_target
      if y_target is not None:
        single_y_target = np.expand_dims(y_target[i], axis=0)
        kwargs['y_target'] = single_y_target

      adv_img = super(BoundaryAttackPlusPlus,
                      self).generate_np(img, **kwargs)
      x_adv.append(adv_img)

    return np.concatenate(x_adv, axis=0)