code: def compute_image_size_affine_transform(
      original_image_size,
      input_image_size,
      padding_keep_size=127,
      random=False,
      random_side_scale_range=None,
  ):
      """Computer affine transform."""
      if input_image_size is None:
          input_h = (
              tf.bitwise.bitwise_or(
                  original_image_size[-2], padding_keep_size
              )
              + 1
          )
          input_w = (
              tf.bitwise.bitwise_or(
                  original_image_size[-1], padding_keep_size
              )
              + 1
          )
          input_size = tf.cast(tf.stack([input_w, input_h]), tf.float32)
          side_size = tf.cast(tf.stack([input_w, input_h]), tf.float32)
          center = tf.cast(
              tf.stack(
                  [
                      original_image_size[-1] // 2,
                      original_image_size[-2] // 2,
                  ]
              ),
              tf.float32,
          )
      else:
          input_size = tf.cast(tf.stack(input_image_size), tf.float32)
          max_side = tf.reduce_max(original_image_size[-2:])
          side_size = tf.cast(
              tf.stack([max_side, max_side]), tf.float32
          )
          image_shape = tf.cast(original_image_size, tf.float32)
          center = tf.stack(
              [image_shape[-1] / 2.0, image_shape[-2] / 2.0]
          )
  
      if random:
          assert random_side_scale_range is not None, (
              "Random random_side_scale_range has to be provided when computing "
              "random affine transformation!"
          )
          scales = tf.range(*random_side_scale_range)
          scale_ii = tf.random.categorical(
              tf.ones_like(scales)[None, ...], 1, dtype=tf.int32
          )[0, 0]
          side_size = side_size * scales[scale_ii]
          h_border = _get_image_border(128, original_image_size[-2])
          w_border = _get_image_border(128, original_image_size[-1])
          center_x = tf.random.uniform(
              [1],
              dtype=tf.int32,
              minval=w_border,
              maxval=(original_image_size[-1] - w_border),
          )[0]
          center_y = tf.random.uniform(
              [1],
              dtype=tf.int32,
              minval=h_border,
              maxval=(original_image_size[-2] - h_border),
          )[0]
          center = tf.cast(tf.stack([center_x, center_y]), tf.float32)
  
      return center, side_size, input_size
  
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 10 for calling a global function with example usage: compute_image_size_affine_transform(original_image_size, input_image_size, padding_keep_size, random, random_side_scale_range) and returns: center,  side_size,  input_size