def _cutout_inside_bbox(image, bbox, pad_fraction):
    'Generates cutout mask and the mean pixel value of the bbox.\n\n  First a location is randomly chosen within the image as the center where the\n  cutout mask will be applied. Note this can be towards the boundaries of the\n  image, so the full cutout mask may not be applied.\n\n  Args:\n    image: 3D uint8 Tensor.\n    bbox: 1D Tensor that has 4 elements (min_y, min_x, max_y, max_x)\n      of type float that represents the normalized coordinates between 0 and 1.\n    pad_fraction: Float that specifies how large the cutout mask should be in\n      in reference to the size of the original bbox. If pad_fraction is 0.25,\n      then the cutout mask will be of shape\n      (0.25 * bbox height, 0.25 * bbox width).\n\n  Returns:\n    A tuple. Fist element is a tensor of the same shape as image where each\n    element is either a 1 or 0 that is used to determine where the image\n    will have cutout applied. The second element is the mean of the pixels\n    in the image where the bbox is located.\n  '
    image_height = tf.maximum(tf.shape(image)[0], 10)
    image_width = tf.maximum(tf.shape(image)[1], 10)
    bbox = tf.squeeze(bbox)
    min_y = tf.to_int32((tf.to_float(image_height) * bbox[0]))
    min_x = tf.to_int32((tf.to_float(image_width) * bbox[1]))
    max_y = tf.to_int32((tf.to_float(image_height) * bbox[2]))
    max_x = tf.to_int32((tf.to_float(image_width) * bbox[3]))
    mean = tf.reduce_mean(image[min_y:(max_y + 1), min_x:(max_x + 1)], reduction_indices=[0, 1])
    box_height = ((max_y - min_y) + 1)
    box_width = ((max_x - min_x) + 1)
    pad_size_height = tf.to_int32((pad_fraction * (box_height / 2)))
    pad_size_width = tf.to_int32((pad_fraction * (box_width / 2)))
    cutout_center_height = tf.random_uniform(shape=[], minval=min_y, maxval=(max_y + 1), dtype=tf.int32)
    cutout_center_width = tf.random_uniform(shape=[], minval=min_x, maxval=(max_x + 1), dtype=tf.int32)
    lower_pad = tf.maximum(0, (cutout_center_height - pad_size_height))
    upper_pad = tf.maximum(0, ((image_height - cutout_center_height) - pad_size_height))
    left_pad = tf.maximum(0, (cutout_center_width - pad_size_width))
    right_pad = tf.maximum(0, ((image_width - cutout_center_width) - pad_size_width))
    cutout_shape = [(image_height - (lower_pad + upper_pad)), (image_width - (left_pad + right_pad))]
    padding_dims = [[lower_pad, upper_pad], [left_pad, right_pad]]
    mask = tf.pad(tf.zeros(cutout_shape, dtype=image.dtype), padding_dims, constant_values=1)
    mask = tf.expand_dims(mask, 2)
    mask = tf.tile(mask, [1, 1, 3])
    return (mask, mean)
Generates cutout mask and the mean pixel value of the bbox.

First a location is randomly chosen within the image as the center where the
cutout mask will be applied. Note this can be towards the boundaries of the
image, so the full cutout mask may not be applied.

Args:
  image: 3D uint8 Tensor.
  bbox: 1D Tensor that has 4 elements (min_y, min_x, max_y, max_x)
    of type float that represents the normalized coordinates between 0 and 1.
  pad_fraction: Float that specifies how large the cutout mask should be in
    in reference to the size of the original bbox. If pad_fraction is 0.25,
    then the cutout mask will be of shape
    (0.25 * bbox height, 0.25 * bbox width).

Returns:
  A tuple. Fist element is a tensor of the same shape as image where each
  element is either a 1 or 0 that is used to determine where the image
  will have cutout applied. The second element is the mean of the pixels
  in the image where the bbox is located.
def _cutout_inside_bbox(image, bbox, pad_fraction):
    'Generates cutout mask and the mean pixel value of the bbox.\n\n  First a location is randomly chosen within the image as the center where the\n  cutout mask will be applied. Note this can be towards the boundaries of the\n  image, so the full cutout mask may not be applied.\n\n  Args:\n    image: 3D uint8 Tensor.\n    bbox: 1D Tensor that has 4 elements (min_y, min_x, max_y, max_x)\n      of type float that represents the normalized coordinates between 0 and 1.\n    pad_fraction: Float that specifies how large the cutout mask should be in\n      in reference to the size of the original bbox. If pad_fraction is 0.25,\n      then the cutout mask will be of shape\n      (0.25 * bbox height, 0.25 * bbox width).\n\n  Returns:\n    A tuple. Fist element is a tensor of the same shape as image where each\n    element is either a 1 or 0 that is used to determine where the image\n    will have cutout applied. The second element is the mean of the pixels\n    in the image where the bbox is located.\n  '
    image_height = tf.maximum(tf.shape(image)[0], 10)
    image_width = tf.maximum(tf.shape(image)[1], 10)
    bbox = tf.squeeze(bbox)
    min_y = tf.to_int32((tf.to_float(image_height) * bbox[0]))
    min_x = tf.to_int32((tf.to_float(image_width) * bbox[1]))
    max_y = tf.to_int32((tf.to_float(image_height) * bbox[2]))
    max_x = tf.to_int32((tf.to_float(image_width) * bbox[3]))
    mean = tf.reduce_mean(image[min_y:(max_y + 1), min_x:(max_x + 1)], reduction_indices=[0, 1])
    box_height = ((max_y - min_y) + 1)
    box_width = ((max_x - min_x) + 1)
    pad_size_height = tf.to_int32((pad_fraction * (box_height / 2)))
    pad_size_width = tf.to_int32((pad_fraction * (box_width / 2)))
    cutout_center_height = tf.random_uniform(shape=[], minval=min_y, maxval=(max_y + 1), dtype=tf.int32)
    cutout_center_width = tf.random_uniform(shape=[], minval=min_x, maxval=(max_x + 1), dtype=tf.int32)
    lower_pad = tf.maximum(0, (cutout_center_height - pad_size_height))
    upper_pad = tf.maximum(0, ((image_height - cutout_center_height) - pad_size_height))
    left_pad = tf.maximum(0, (cutout_center_width - pad_size_width))
    right_pad = tf.maximum(0, ((image_width - cutout_center_width) - pad_size_width))
    cutout_shape = [(image_height - (lower_pad + upper_pad)), (image_width - (left_pad + right_pad))]
    padding_dims = [[lower_pad, upper_pad], [left_pad, right_pad]]
    mask = tf.pad(tf.zeros(cutout_shape, dtype=image.dtype), padding_dims, constant_values=1)
    mask = tf.expand_dims(mask, 2)
    mask = tf.tile(mask, [1, 1, 3])
    return (mask, mean)