class_docstr: Implementation of backdoor attacks introduced in Gu et al., 2017.
  
  Applies a number of backdoor perturbation functions and switches label to target label
  
  | Paper link: https://arxiv.org/abs/1708.06733
docstr: Calls perturbation function on input x and returns the perturbed input and poison labels for the data.
  
  :param x: An array with the points that initialize attack points.
  :param y: The target labels for the attack.
  :param broadcast: whether or not to broadcast single target label
  :return: An tuple holding the `(poisoning_examples, poisoning_labels)`.
code: def poison(  # pylint: disable=W0221
      self,
      x: np.ndarray,
      y: Optional[np.ndarray] = None,
      broadcast=False,
      **kwargs,
  ) -> Tuple[np.ndarray, np.ndarray]:
      """
      Calls perturbation function on input x and returns the perturbed input and poison labels for the data.
  
      :param x: An array with the points that initialize attack points.
      :param y: The target labels for the attack.
      :param broadcast: whether or not to broadcast single target label
      :return: An tuple holding the `(poisoning_examples, poisoning_labels)`.
      """
      if y is None:  # pragma: no cover
          raise ValueError(
              "Target labels `y` need to be provided for a targeted attack."
          )
  
      if broadcast:
          y_attack = np.broadcast_to(y, (x.shape[0], y.shape[0]))
      else:
          y_attack = np.copy(y)
  
      num_poison = len(x)
      if num_poison == 0:  # pragma: no cover
          raise ValueError("Must input at least one poison point.")
      poisoned = np.copy(x)
  
      if callable(self.perturbation):
          return self.perturbation(poisoned), y_attack
  
      for perturb in self.perturbation:
          poisoned = perturb(poisoned)
  
      return poisoned, y_attack
  
file_path: adversarial-robustness-toolbox/art/attacks/poisoning/backdoor_attack.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Callable, List, Optional, Tuple, Union
  import numpy
  from art.attacks.attack import PoisoningAttackBlackBox
label_desc: Use image node_id 2 for calling the PoisoningAttackBackdoor obj's underlying member method code with example usage: obj.poison(x, y, broadcast) and returns: poisoned,  y_attack, self,  y_attack