code: def test_targeted_attacks_call_raises_exception(
      fmodel_and_data_ext_for_attacks: ModeAndDataAndDescription,
      attack_exception_text_and_grad: Tuple[fbn.Attack, bool],
  ) -> None:
      attack, attack_uses_grad = attack_exception_text_and_grad
      (fmodel, x, y), _, _ = fmodel_and_data_ext_for_attacks
  
      if isinstance(x, ep.NumPyTensor) and attack_uses_grad:
          pytest.skip()
  
      x = (x - fmodel.bounds.lower) / (
          fmodel.bounds.upper - fmodel.bounds.lower
      )
      fmodel = fmodel.transform_bounds((0, 1))
  
      num_classes = fmodel(x).shape[-1]
      target_classes = (y + 1) % num_classes
      invalid_target_classes = ep.concatenate(
          (target_classes, target_classes), 0
      )
      invalid_targeted_criterion = fbn.TargetedMisclassification(
          invalid_target_classes
      )
  
      class DummyCriterion(fbn.Criterion):
          """Criterion without any functionality which is just meant to be
          rejected by the attacks
          """
  
          def __repr__(self) -> str:
              return ""
  
          def __call__(
              self, perturbed: fbn.criteria.T, outputs: fbn.criteria.T
          ) -> fbn.criteria.T:
              return perturbed
  
      invalid_criterion = DummyCriterion()
  
      # check if targeted attack criterion with invalid number of classes is rejected
      with pytest.raises(ValueError):
          attack(fmodel, x, invalid_targeted_criterion, epsilons=1000.0)
  
      # check if only the two valid criteria are accepted
      with pytest.raises(ValueError):
          attack(fmodel, x, invalid_criterion, epsilons=1000.0)
  
file_path: foolbox/tests/test_attacks_raise.py
imports: from typing import List, Tuple, Any
  import pytest
  import eagerpy
  import foolbox
  from conftest import ModeAndDataAndDescription
label_desc: Use image node_id 13 for calling a global function with example usage: test_targeted_attacks_call_raises_exception(fmodel_and_data_ext_for_attacks, attack_exception_text_and_grad) and returns: str, perturbed