code: def test_poison(
      art_warning,
      get_default_mnist_subset,
      image_dl_estimator,
      framework,
  ):
      try:
          (x_train, y_train), (_, _) = get_default_mnist_subset
          classifier, _ = image_dl_estimator()
          target = to_categorical([9], 10)[0]
          print(x_train.shape)
  
          def mod(x):
              return add_pattern_bd(
                  x, channels_first=classifier.channels_first
              )
  
          backdoor = PoisoningAttackBackdoor(mod)
          attack = PoisoningAttackCleanLabelBackdoor(
              backdoor, classifier, target
          )
          poison_data, poison_labels = attack.poison(x_train, y_train)
  
          np.testing.assert_equal(poison_data.shape, x_train.shape)
          np.testing.assert_equal(poison_labels.shape, y_train.shape)
      except ARTTestException as e:
          art_warning(e)
  
file_path: adversarial-robustness-toolbox/tests/attacks/poison/test_clean_label_backdoor_attack.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import numpy
  import pytest
  from art.attacks.poisoning import PoisoningAttackCleanLabelBackdoor, PoisoningAttackBackdoor
  from art.attacks.poisoning.perturbations import add_pattern_bd
  from art.utils import to_categorical
  from tests.utils import ARTTestException
label_desc: Use image node_id 1 for calling a global function with example usage: test_poison(art_warning, get_default_mnist_subset, image_dl_estimator, framework) and returns: add_pattern_bd