code: def rotate_bboxes_helper(
      bbox: Tuple, src_w: int, src_h: int, degrees: float, **kwargs
  ) -> Tuple:
      """
      Computes the bbox that encloses the rotated bbox in the rotated image. This code was
      informed by looking at the source code for PIL.Image.rotate
      (https://pillow.readthedocs.io/en/stable/_modules/PIL/Image.html#Image.rotate).
      Also uses the `crop_bboxes_helper` function since the image is cropped after being
      rotated.
      """
      left_f, upper_f, right_f, lower_f = bbox
      left, upper, right, lower = (
          left_f * src_w,
          upper_f * src_h,
          right_f * src_w,
          lower_f * src_h,
      )
      # Top left, upper right, lower right, & lower left corner coefficients (in pixels)
      bbox_corners = [
          (left, upper),
          (right, upper),
          (right, lower),
          (left, lower),
      ]
  
      def transform(
          x: int, y: int, matrix: List[float]
      ) -> Tuple[float, float]:
          (a, b, c, d, e, f) = matrix
          return a * x + b * y + c, d * x + e * y + f
  
      def get_enclosing_bbox(
          corners: List[Tuple[int, int]], rotation_matrix: List[float]
      ) -> Tuple[int, int, int, int]:
          rotated_corners = [
              transform(x, y, rotation_matrix) for x, y in corners
          ]
          xs, ys = zip(*rotated_corners)
          return (
              math.floor(min(xs)),
              math.floor(min(ys)),
              math.ceil(max(xs)),
              math.ceil(max(ys)),
          )
  
      # Get rotated bbox corner coefficients
      rotation_center = (src_w // 2, src_h // 2)
      angle_rad = -math.radians(degrees)
      rotation_matrix = [
          round(math.cos(angle_rad), 15),
          round(math.sin(angle_rad), 15),
          0.0,
          round(math.sin(angle_rad), 15),
          round(-math.cos(angle_rad), 15),
          0.0,
      ]
      rotation_matrix[2], rotation_matrix[5] = transform(
          -rotation_center[0], -rotation_center[1], rotation_matrix
      )
      rotation_matrix[2] += rotation_center[0]
      rotation_matrix[5] += rotation_center[1]
  
      # Get rotated image dimensions
      src_img_corners = [(0, 0), (src_w, 0), (src_w, src_h), (0, src_h)]
      (
          rotated_img_min_x,
          rotated_img_min_y,
          rotated_img_max_x,
          rotated_img_max_y,
      ) = get_enclosing_bbox(src_img_corners, rotation_matrix)
      rotated_img_w = rotated_img_max_x - rotated_img_min_x
      rotated_img_h = rotated_img_max_y - rotated_img_min_y
  
      # Get enclosing box corners around rotated bbox (on rotated image)
      (
          new_bbox_left,
          new_bbox_upper,
          new_bbox_right,
          new_bbox_lower,
      ) = get_enclosing_bbox(bbox_corners, rotation_matrix)
      bbox_enclosing_bbox = (
          new_bbox_left / rotated_img_w,
          new_bbox_upper / rotated_img_h,
          new_bbox_right / rotated_img_w,
          new_bbox_lower / rotated_img_h,
      )
  
      # Crop bbox as src image is cropped inside `rotate`
      cropped_w, cropped_h = imutils.rotated_rect_with_max_area(
          src_w, src_h, degrees
      )
      (
          cropped_img_left,
          cropped_img_upper,
          cropped_img_right,
          cropped_img_lower,
      ) = (
          (rotated_img_w - cropped_w) // 2 + rotated_img_min_x,
          (rotated_img_h - cropped_h) // 2 + rotated_img_min_y,
          (rotated_img_w + cropped_w) // 2 + rotated_img_min_x,
          (rotated_img_h + cropped_h) // 2 + rotated_img_min_y,
      )
      return crop_bboxes_helper(
          bbox_enclosing_bbox,
          x1=cropped_img_left / rotated_img_w,
          y1=cropped_img_upper / rotated_img_h,
          x2=cropped_img_right / rotated_img_w,
          y2=cropped_img_lower / rotated_img_h,
      )
  
file_path: AugLy/augly/image/utils/bboxes.py
imports: import math
  from typing import Callable, List, Optional, Tuple
  import numpy
  from augly.image import utils
  from PIL import Image, ImageDraw
label_desc: Use image node_id 10 for calling a global function with example usage: rotate_bboxes_helper(bbox, src_w, src_h, degrees) and returns: crop_bboxes_helper, unknown,  unknown, math,  math,  math,  math