code: def test_augment_images_with_patch(
      art_warning, channels_first, fix_get_rcnn
  ):
      try:
          frcnn = fix_get_rcnn
          attack = RobustDPatch(
              frcnn,
              patch_shape=(4, 4, 1),
              patch_location=(2, 2),
              crop_range=(0, 0),
              brightness_range=(1.0, 1.0),
              rotation_weights=(1, 0, 0, 0),
              sample_size=1,
              learning_rate=1.0,
              max_iter=1,
              batch_size=1,
              verbose=False,
          )
  
          if channels_first:
              patch = np.ones(shape=(1, 4, 4))
              x = np.zeros(shape=(1, 1, 10, 10))
          else:
              patch = np.ones(shape=(4, 4, 1))
              x = np.zeros(shape=(1, 10, 10, 1))
  
          (
              patched_images,
              _,
              transformations,
          ) = attack._augment_images_with_patch(
              x=x, y=None, patch=patch, channels_first=channels_first
          )
  
          transformation_expected = {
              "crop_x": 0,
              "crop_y": 0,
              "rot90": 0,
              "brightness": 1.0,
          }
          patch_sum_expected = 16.0
          complement_sum_expected = 0.0
  
          if channels_first:
              patch_sum = np.sum(patched_images[0, :, 2:7, 2:7])
          else:
              patch_sum = np.sum(patched_images[0, 2:7, 2:7, :])
  
          complement_sum = np.sum(patched_images[0]) - patch_sum
  
          assert transformations == transformation_expected
  
          assert patch_sum == patch_sum_expected
  
          assert complement_sum == complement_sum_expected
  
      except ARTTestException as e:
          art_warning(e)
  
file_path: adversarial-robustness-toolbox/tests/attacks/evasion/test_dpatch_robust.py
imports: import logging
  import numpy
  import pytest
  from art.attacks.evasion import RobustDPatch
  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 ARTTestException
label_desc: Use image node_id 4 for calling a global function with example usage: test_augment_images_with_patch(art_warning, channels_first, fix_get_rcnn) without return types