code: def polygon_obb(polygon):
      
      if hasattr(polygon, 'exterior'):
          points = np.asanyarray(polygon.exterior.coords)
      elif isinstance(polygon, np.ndarray):
          points = polygon
      else:
          raise ValueError('polygon or points must be provided')
      return bounds.oriented_bounds_2D(points)
docs: Find the oriented bounding box of a Shapely polygon.
  
      The OBB is always aligned with an edge of the convex hull of the polygon.
  
      Parameters
      -------------
      polygons: shapely.geometry.Polygon
  
      Returns
      -------------
      transform: (3,3) float, transformation matrix
                 which will move input polygon from its original position
                 to the first quadrant where the AABB is the OBB
      extents:   (2,) float, extents of transformed polygon