import tensorflow as tf

  image_height, image_width = tf.shape(images)[1], tf.shape(images)[2]

  cutout_center_height = tf.random.uniform(
      shape=[], minval=0, maxval=image_height,
      dtype=tf.int32)
  cutout_center_width = tf.random.uniform(
      shape=[], minval=0, maxval=image_width,
      dtype=tf.int32)

  lower_pad = tf.maximum(0, cutout_center_height - length // 2)
  upper_pad = tf.maximum(0, image_height - cutout_center_height - length // 2)
  left_pad = tf.maximum(0, cutout_center_width - length // 2)
  right_pad = tf.maximum(0, image_width - cutout_center_width - length // 2)

  cutout_shape = [image_height - (lower_pad + upper_pad),
                  image_width - (left_pad + right_pad)]

  padding_dims = [[lower_pad, upper_pad], [left_pad, right_pad]]
