code: def _apply_transformation(inputs):
      x, trans = inputs[0], inputs[1]
      dx, dy, angle = trans[0], trans[1], trans[2]
      height = x.get_shape().as_list()[1]
      width = x.get_shape().as_list()[2]
  
      # Pad the image to prevent two-step rotation / translation from truncating
      # corners
      max_dist_from_center = np.sqrt(height**2 + width**2) / 2
      min_edge_from_center = float(np.min([height, width])) / 2
      padding = np.ceil(
          max_dist_from_center - min_edge_from_center
      ).astype(np.int32)
      x = tf.pad(
          x,
          [[0, 0], [padding, padding], [padding, padding], [0, 0]],
          "CONSTANT",
      )
  
      # Apply rotation
      angle *= np.pi / 180
      x = tfa.image.rotate(x, angle, interpolation="BILINEAR")
  
      # Apply translation
      dx_in_px = -dx * height
      dy_in_px = -dy * width
      translation = tf.convert_to_tensor([dx_in_px, dy_in_px])
  
      try:
          x = tfa.image.translate(
              x, translation, interpolation="BILINEAR"
          )
      except AttributeError as e:
          print("WARNING: SpatialAttack requires tf 1.6 or higher")
          raise e
      x = tfa.image.translate(x, translation, interpolation="BILINEAR")
      return tf.image.resize_image_with_crop_or_pad(x, height, width)
  
imports: import warnings
  import numpy
  from six.moves import xrange
  import tensorflow
  import tensorflow_addons
  from cleverhans.attacks.attack import Attack
  from cleverhans.compat import reduce_mean, reduce_sum, reduce_max
  from cleverhans.model import Model
  from cleverhans import utils_tf
label_desc: Use image node_id 4 for calling a global function with example usage: _apply_transformation(inputs) and returns: tf