code: def _test_image_as_input(self, sign_gradients):
      # We must start a new graph
      tf.reset_default_graph()
  
      # Only import if object detection module is available
      from art.estimators.object_detection.tensorflow_faster_rcnn import (
          TensorFlowFasterRCNN,
      )
      from art.attacks.evasion.shapeshifter import ShapeShifter
  
      # Define object detector
      images = tf.Variable(
          initial_value=np.zeros([1, 28, 28, 1]), dtype=tf.float32
      )
      obj_dec = TensorFlowFasterRCNN(images=images)
  
      # Create labels
      result = obj_dec.predict(self.x_test_mnist[:1].astype(np.float32))
  
      groundtruth_boxes_list = [result[i]["boxes"] for i in range(1)]
      groundtruth_classes_list = [result[i]["labels"] for i in range(1)]
      groundtruth_weights_list = [
          np.ones_like(r) for r in groundtruth_classes_list
      ]
  
      y = {
          "groundtruth_boxes_list": groundtruth_boxes_list,
          "groundtruth_classes_list": groundtruth_classes_list,
          "groundtruth_weights_list": groundtruth_weights_list,
      }
  
      # Define attack
      attack = ShapeShifter(
          estimator=obj_dec,
          random_transform=lambda x: x + 1e-10,
          box_classifier_weight=1.0,
          box_localizer_weight=1.0,
          rpn_classifier_weight=1.0,
          rpn_localizer_weight=1.0,
          box_iou_threshold=0.3,
          box_victim_weight=1.0,
          box_target_weight=1.0,
          box_victim_cw_weight=1.0,
          box_victim_cw_confidence=1.0,
          box_target_cw_weight=1.0,
          box_target_cw_confidence=1.0,
          rpn_iou_threshold=0.3,
          rpn_background_weight=1.0,
          rpn_foreground_weight=1.0,
          rpn_cw_weight=1.0,
          rpn_cw_confidence=1.0,
          similarity_weight=1.0,
          learning_rate=0.1,
          optimizer="RMSPropOptimizer",
          momentum=0.01,
          decay=0.01,
          sign_gradients=sign_gradients,
          random_size=2,
          max_iter=2,
          texture_as_input=False,
          use_spectral=False,
          soft_clip=True,
      )
  
      # Targeted attack
      adv_x = attack.generate(
          x=self.x_test_mnist[:1].astype(np.float32),
          label=y,
          target_class=2,
          victim_class=5,
      )
  
      self.assertTrue(adv_x.shape == (1, 28, 28, 1))
      self.assertTrue((adv_x >= 0).all())
      self.assertTrue((adv_x <= 1).all())
  
      # Untargeted attack
      adv_x = attack.generate(
          x=self.x_test_mnist[:1].astype(np.float32),
          label=y,
          victim_class=8,
      )
  
      self.assertTrue(adv_x.shape == (1, 28, 28, 1))
      self.assertTrue((adv_x >= 0).all())
      self.assertTrue((adv_x <= 1).all())
  
file_path: adversarial-robustness-toolbox/tests/attacks/test_shapeshifter.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import unittest
  import importlib
  import tensorflow
  import numpy
  from tests.utils import TestBase, master_seed
label_desc: Use image node_id 3 for calling the TestShapeShifter obj's underlying member method code with example usage: obj._test_image_as_input(sign_gradients) without return types