def bundle_attacks_with_goal(sess, model, x, y, adv_x, attack_configs,
                             run_counts,
                             goal, report, report_path,
                             attack_batch_size=BATCH_SIZE, eval_batch_size=BATCH_SIZE):
  """
  Runs attack bundling, working on one specific AttackGoal.
  This function is mostly intended to be called by `bundle_attacks`.

  Reference: https://openreview.net/forum?id=H1g0piA9tQ

  :param sess: tf.session.Session
  :param model: cleverhans.model.Model
  :param x: numpy array containing clean example inputs to attack
  :param y: numpy array containing true labels
  :param adv_x: numpy array containing the adversarial examples made so far
    by earlier work in the bundling process
  :param attack_configs: list of AttackConfigs to run
  :param run_counts: dict mapping AttackConfigs to numpy arrays specifying
    how many times they have been run on each example
  :param goal: AttackGoal to run
  :param report: ConfidenceReport
  :param report_path: str, the path the report will be saved to
  :param attack_batch_size: int, batch size for generating adversarial examples
  :param eval_batch_size: int, batch size for evaluating the model on adversarial examples
  """
  goal.start(run_counts)
  _logger.info("Running criteria for new goal...")
  criteria = goal.get_criteria(sess, model, adv_x, y, batch_size=eval_batch_size)
  assert 'correctness' in criteria
  _logger.info("Accuracy: " + str(criteria['correctness'].mean()))
  assert 'confidence' in criteria
  while not goal.is_satisfied(criteria, run_counts):
    run_batch_with_goal(sess, model, x, y, adv_x, criteria, attack_configs,
                        run_counts,
                        goal, report, report_path,
                        attack_batch_size=attack_batch_size)
  # Save after finishing all goals.
  # The incremental saves run on a timer. This save is needed so that the last
  # few attacks after the timer don't get discarded
  report.completed = True
  save(criteria, report, report_path, adv_x)
Runs attack bundling, working on one specific AttackGoal.
  This function is mostly intended to be called by `bundle_attacks`.

  Reference: https://openreview.net/forum?id=H1g0piA9tQ

  :param sess: tf.session.Session
  :param model: cleverhans.model.Model
  :param x: numpy array containing clean example inputs to attack
  :param y: numpy array containing true labels
  :param adv_x: numpy array containing the adversarial examples made so far
    by earlier work in the bundling process
  :param attack_configs: list of AttackConfigs to run
  :param run_counts: dict mapping AttackConfigs to numpy arrays specifying
    how many times they have been run on each example
  :param goal: AttackGoal to run
  :param report: ConfidenceReport
  :param report_path: str, the path the report will be saved to
  :param attack_batch_size: int, batch size for generating adversarial examples
  :param eval_batch_size: int, batch size for evaluating the model on adversarial examples