def _shear_bbox(bbox, image_height, image_width, level, shear_horizontal):
    'Shifts the bbox according to how the image was sheared.\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    level: Float. How much to shear the image.\n    shear_horizontal: If true then shear in X dimension else shear in\n      the Y dimension.\n\n  Returns:\n    A tensor of the same shape as bbox, but now with the shifted coordinates.\n  '
    (image_height, image_width) = (tf.to_float(image_height), tf.to_float(image_width))
    min_y = tf.to_int32((image_height * bbox[0]))
    min_x = tf.to_int32((image_width * bbox[1]))
    max_y = tf.to_int32((image_height * bbox[2]))
    max_x = tf.to_int32((image_width * bbox[3]))
    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)
    if shear_horizontal:
        translation_matrix = tf.stack([[1, 0], [(- level), 1]])
    else:
        translation_matrix = tf.stack([[1, (- level)], [0, 1]])
    translation_matrix = tf.cast(translation_matrix, tf.float32)
    new_coords = tf.cast(tf.matmul(translation_matrix, tf.transpose(coordinates)), tf.int32)
    min_y = (tf.to_float(tf.reduce_min(new_coords[0, :])) / image_height)
    min_x = (tf.to_float(tf.reduce_min(new_coords[1, :])) / image_width)
    max_y = (tf.to_float(tf.reduce_max(new_coords[0, :])) / image_height)
    max_x = (tf.to_float(tf.reduce_max(new_coords[1, :])) / image_width)
    (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])
Shifts the bbox according to how the image was sheared.

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.
  level: Float. How much to shear the image.
  shear_horizontal: If true then shear in X dimension else shear in
    the Y dimension.

Returns:
  A tensor of the same shape as bbox, but now with the shifted coordinates.
def _shear_bbox(bbox, image_height, image_width, level, shear_horizontal):
    'Shifts the bbox according to how the image was sheared.\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    level: Float. How much to shear the image.\n    shear_horizontal: If true then shear in X dimension else shear in\n      the Y dimension.\n\n  Returns:\n    A tensor of the same shape as bbox, but now with the shifted coordinates.\n  '
    (image_height, image_width) = (tf.to_float(image_height), tf.to_float(image_width))
    min_y = tf.to_int32((image_height * bbox[0]))
    min_x = tf.to_int32((image_width * bbox[1]))
    max_y = tf.to_int32((image_height * bbox[2]))
    max_x = tf.to_int32((image_width * bbox[3]))
    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)
    if shear_horizontal:
        translation_matrix = tf.stack([[1, 0], [(- level), 1]])
    else:
        translation_matrix = tf.stack([[1, (- level)], [0, 1]])
    translation_matrix = tf.cast(translation_matrix, tf.float32)
    new_coords = tf.cast(tf.matmul(translation_matrix, tf.transpose(coordinates)), tf.int32)
    min_y = (tf.to_float(tf.reduce_min(new_coords[0, :])) / image_height)
    min_x = (tf.to_float(tf.reduce_min(new_coords[1, :])) / image_width)
    max_y = (tf.to_float(tf.reduce_max(new_coords[0, :])) / image_height)
    max_x = (tf.to_float(tf.reduce_max(new_coords[1, :])) / image_width)
    (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])