code: def test_augment_images_with_patch(
      art_warning, random_location, image_format, fix_get_mnist_subset
  ):
      try:
          (
              x_train_mnist,
              y_train_mnist,
              x_test_mnist,
              y_test_mnist,
          ) = fix_get_mnist_subset
  
          # TODO this master_seed should be removed as it is already set in conftest.py. expected values will
          # need to be updated accordingly
          master_seed()
  
          if image_format == "NHWC":
              patch = np.ones(shape=(4, 4, 1)) * 0.5
              x = x_train_mnist[0:3]
              channels_first = False
          elif image_format == "NCHW":
              patch = np.ones(shape=(1, 4, 4)) * 0.5
              x = np.transpose(x_train_mnist[0:3], (0, 3, 1, 2))
              channels_first = True
          else:
              raise ValueError(
                  "Value of `image_format` not recognized."
              )
  
          (
              patched_images,
              transformations,
          ) = DPatch._augment_images_with_patch(
              x=x,
              patch=patch,
              random_location=random_location,
              channels_first=channels_first,
          )
  
          if random_location:
              transformation_expected = {
                  "i_x_1": 0,
                  "i_y_1": 2,
                  "i_x_2": 4,
                  "i_y_2": 6,
              }
              patched_images_column = [
                  0.0,
                  0.0,
                  0.5,
                  0.5,
                  0.5,
                  0.5,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
              ]
          else:
              transformation_expected = {
                  "i_x_1": 0,
                  "i_y_1": 0,
                  "i_x_2": 4,
                  "i_y_2": 4,
              }
              patched_images_column = [
                  0.5,
                  0.5,
                  0.5,
                  0.5,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
                  0.0,
              ]
  
          assert transformations[1] == transformation_expected
  
          if image_format == "NCHW":
              patched_images = np.transpose(
                  patched_images, (0, 2, 3, 1)
              )
  
          np.testing.assert_array_equal(
              patched_images[1, 2, :, 0], patched_images_column
          )
      except ARTTestException as e:
          art_warning(e)
  
file_path: adversarial-robustness-toolbox/tests/attacks/evasion/test_dpatch.py
imports: import logging
  import numpy
  import pytest
  from art.attacks.evasion import DPatch
  from art.estimators.estimator import BaseEstimator, LossGradientsMixin
  from art.estimators.object_detection.object_detector import ObjectDetectorMixin
  from tests.attacks.utils import backend_test_classifier_type_check_fail
  from tests.utils import master_seed
  from tests.utils import ARTTestException
label_desc: Use image node_id 3 for calling a global function with example usage: test_augment_images_with_patch(art_warning, random_location, image_format, fix_get_mnist_subset) without return types