def _rotate_bbox(bbox, image_height, image_width, degrees):
    'Rotates the bbox coordinated by degrees.\n\n  Args:\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    image_height: Int, height of the image.\n    image_width: Int, height of the image.\n    degrees: Float, a scalar angle in degrees to rotate all images by. If\n      degrees is positive the image will be rotated clockwise otherwise it will\n      be rotated counterclockwise.\n\n  Returns:\n    A tensor of the same shape as bbox, but now with the rotated coordinates.\n  '
    (image_height, image_width) = (tf.to_float(image_height), tf.to_float(image_width))
    degrees_to_radians = (math.pi / 180.0)
    radians = (degrees * degrees_to_radians)
    min_y = (- tf.to_int32((image_height * (bbox[0] - 0.5))))
    min_x = tf.to_int32((image_width * (bbox[1] - 0.5)))
    max_y = (- tf.to_int32((image_height * (bbox[2] - 0.5))))
    max_x = tf.to_int32((image_width * (bbox[3] - 0.5)))
    coordinates = tf.stack([[min_y, min_x], [min_y, max_x], [max_y, min_x], [max_y, max_x]])
    coordinates = tf.cast(coordinates, tf.float32)
    rotation_matrix = tf.stack([[tf.cos(radians), tf.sin(radians)], [(- tf.sin(radians)), tf.cos(radians)]])
    new_coords = tf.cast(tf.matmul(rotation_matrix, tf.transpose(coordinates)), tf.int32)
    min_y = (- ((tf.to_float(tf.reduce_max(new_coords[0, :])) / image_height) - 0.5))
    min_x = ((tf.to_float(tf.reduce_min(new_coords[1, :])) / image_width) + 0.5)
    max_y = (- ((tf.to_float(tf.reduce_min(new_coords[0, :])) / image_height) - 0.5))
    max_x = ((tf.to_float(tf.reduce_max(new_coords[1, :])) / image_width) + 0.5)
    (min_y, min_x, max_y, max_x) = _clip_bbox(min_y, min_x, max_y, max_x)
    (min_y, min_x, max_y, max_x) = _check_bbox_area(min_y, min_x, max_y, max_x)
    return tf.stack([min_y, min_x, max_y, max_x])
Rotates the bbox coordinated by degrees.

Args:
  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.
  image_height: Int, height of the image.
  image_width: Int, height of the image.
  degrees: Float, a scalar angle in degrees to rotate all images by. If
    degrees is positive the image will be rotated clockwise otherwise it will
    be rotated counterclockwise.

Returns:
  A tensor of the same shape as bbox, but now with the rotated coordinates.
def _rotate_bbox(bbox, image_height, image_width, degrees):
    'Rotates the bbox coordinated by degrees.\n\n  Args:\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    image_height: Int, height of the image.\n    image_width: Int, height of the image.\n    degrees: Float, a scalar angle in degrees to rotate all images by. If\n      degrees is positive the image will be rotated clockwise otherwise it will\n      be rotated counterclockwise.\n\n  Returns:\n    A tensor of the same shape as bbox, but now with the rotated coordinates.\n  '
    (image_height, image_width) = (tf.to_float(image_height), tf.to_float(image_width))
    degrees_to_radians = (math.pi / 180.0)
    radians = (degrees * degrees_to_radians)
    min_y = (- tf.to_int32((image_height * (bbox[0] - 0.5))))
    min_x = tf.to_int32((image_width * (bbox[1] - 0.5)))
    max_y = (- tf.to_int32((image_height * (bbox[2] - 0.5))))
    max_x = tf.to_int32((image_width * (bbox[3] - 0.5)))
    coordinates = tf.stack([[min_y, min_x], [min_y, max_x], [max_y, min_x], [max_y, max_x]])
    coordinates = tf.cast(coordinates, tf.float32)
    rotation_matrix = tf.stack([[tf.cos(radians), tf.sin(radians)], [(- tf.sin(radians)), tf.cos(radians)]])
    new_coords = tf.cast(tf.matmul(rotation_matrix, tf.transpose(coordinates)), tf.int32)
    min_y = (- ((tf.to_float(tf.reduce_max(new_coords[0, :])) / image_height) - 0.5))
    min_x = ((tf.to_float(tf.reduce_min(new_coords[1, :])) / image_width) + 0.5)
    max_y = (- ((tf.to_float(tf.reduce_min(new_coords[0, :])) / image_height) - 0.5))
    max_x = ((tf.to_float(tf.reduce_max(new_coords[1, :])) / image_width) + 0.5)
    (min_y, min_x, max_y, max_x) = _clip_bbox(min_y, min_x, max_y, max_x)
    (min_y, min_x, max_y, max_x) = _check_bbox_area(min_y, min_x, max_y, max_x)
    return tf.stack([min_y, min_x, max_y, max_x])