code: def affine_transform(
      image,
      original_image_size,
      bounding_boxes,
      instance_masks,
      image_size,
      padding_keep_size=127,
      transform_gt_annotations=False,
      random=False,
      random_side_scale_range=None,
      random_flip_probability=False,
  ):
      """Affine transform."""
      # bounding_boxes: normalized coordinates with (ymin, xmin, ymax, xmax)
      (
          center,
          side_size,
          input_size,
      ) = compute_image_size_affine_transform(
          tf.shape(image)[:-1],
          image_size,
          padding_keep_size,
          random,
          random_side_scale_range,
      )
      flipped = False
      if random:
  
          def _flip(flipped, image, center):
              flipped = tf.math.logical_not(flipped)
              image = image[..., ::-1, :]
              center = tf.tensor_scatter_nd_update(
                  center,
                  tf.constant([[0]]),
                  [
                      tf.cast(tf.shape(image)[-2], center.dtype)
                      - center[0]
                  ],
              )
              return flipped, image, center
  
          def _no_flip(flipped, image, center):
              return flipped, image, center
  
          flipped, image, center = tf.cond(
              tf.random.uniform([1], dtype=tf.float32)[0]
              < random_flip_probability,
              lambda: _flip(flipped, image, center),
              lambda: _no_flip(flipped, image, center),
          )
  
          if instance_masks is not None:
  
              def _flip_mask(mask):
                  return mask[..., ::-1]
  
              def _no_flip_mask(mask):
                  return mask
  
              instance_masks = tf.cond(
                  flipped,
                  lambda: _flip_mask(instance_masks),
                  lambda: _no_flip_mask(instance_masks),
              )
  
      # affine_transform_image_np(image, center, side_size, input_size)
      input_image_size_static = image.shape
      [
          image,
      ] = tf.py_function(
          affine_transform_image_np,
          [image, center, side_size, input_size],
          [tf.float32],
      )
      if len(input_image_size_static) == 4:
          image.set_shape([image.shape[0], None, None, image.shape[-1]])
      else:
          image.set_shape([None, None, image.shape[-1]])
  
      if transform_gt_annotations:
          bounding_boxes_shape = bounding_boxes.shape
  
          [
              bounding_boxes,
          ] = tf.py_function(
              _affine_transform_points_np,
              [
                  bounding_boxes,
                  original_image_size,
                  center,
                  side_size,
                  input_size,
                  flipped,
              ],
              [tf.float32],
          )
          bounding_boxes.set_shape(bounding_boxes_shape)
  
          if instance_masks is not None:
              instance_masks_size_static = instance_masks.shape
              [
                  instance_masks,
              ] = tf.py_function(
                  affine_transform_image_np,
                  [
                      instance_masks[..., None],
                      center,
                      side_size,
                      input_size,
                      cv2.INTER_NEAREST,
                  ],
                  [tf.float32],
              )
              if len(instance_masks_size_static) == 4:
                  instance_masks.set_shape(
                      [instance_masks.shape[0], None, None, None, 1]
                  )
              else:
                  instance_masks.set_shape([None, None, None, 1])
              instance_masks = instance_masks[..., 0]
  
          original_image_size = tf.cast(
              input_size, original_image_size.dtype
          )
  
      return image, original_image_size, bounding_boxes, instance_masks
  
imports: import functools
  import cv2
  import numpy
  import tensorflow
  from tensorflow_graphics.projects.points_to_3Dobjects.utils import image
  from google3.third_party.tensorflow_models.object_detection.core import preprocessor
label_desc: Use image node_id 11 for calling a global function with example usage: affine_transform(image, original_image_size, bounding_boxes, instance_masks, image_size, padding_keep_size, transform_gt_annotations, random, random_side_scale_range, random_flip_probability) and returns: image,  original_image_size,  bounding_boxes,  instance_masks, flipped,  image,  center, flipped,  image,  center, mask, mask