(startpoints: List[List[int]],
                            endpoints: List[List[int]])
return output
Helper function to get the coefficients (a, b, c, d, e, f, g, h) for the perspective transforms.

    In Perspective Transform each pixel (x, y) in the original image gets transformed as,
     (x, y) -> ( (ax + by + c) / (gx + hy + 1), (dx + ey + f) / (gx + hy + 1) )

    Args:
        startpoints (list of list of ints): List containing four lists of two integers corresponding to four corners
            ``[top-left, top-right, bottom-right, bottom-left]`` of the original image.
        endpoints (list of list of ints): List containing four lists of two integers corresponding to four corners
            ``[top-left, top-right, bottom-right, bottom-left]`` of the transformed image.

    Returns:
        octuple (a, b, c, d, e, f, g, h) for transforming each pixel.
Helper function to get the coefficients (a, b, c, d, e, f, g, h) for the perspective transforms.
Helper function to get the coefficients ( a b c d e f g h ) for the perspective transforms .
def _get_perspective_coeffs(startpoints: List[List[int]],
                            endpoints: List[List[int]]) -> List[float]:
    """Helper function to get the coefficients (a, b, c, d, e, f, g, h) for the perspective transforms.

    In Perspective Transform each pixel (x, y) in the original image gets transformed as,
     (x, y) -> ( (ax + by + c) / (gx + hy + 1), (dx + ey + f) / (gx + hy + 1) )

    Args:
        startpoints (list of list of ints): List containing four lists of two integers corresponding to four corners
            ``[top-left, top-right, bottom-right, bottom-left]`` of the original image.
        endpoints (list of list of ints): List containing four lists of two integers corresponding to four corners
            ``[top-left, top-right, bottom-right, bottom-left]`` of the transformed image.

    Returns:
        octuple (a, b, c, d, e, f, g, h) for transforming each pixel.
    """
    a_matrix = torch.zeros(2 * len(startpoints), 8, dtype=torch.float)

    for i, (p1, p2) in enumerate(zip(endpoints, startpoints)):
        a_matrix[2 * i, :] = torch.tensor(
            [p1[0], p1[1], 1, 0, 0, 0, -p2[0] * p1[0], -p2[0] * p1[1]])
        a_matrix[2 * i + 1, :] = torch.tensor(
            [0, 0, 0, p1[0], p1[1], 1, -p2[1] * p1[0], -p2[1] * p1[1]])

    b_matrix = torch.tensor(startpoints, dtype=torch.float).view(8)
    res = torch.linalg.lstsq(a_matrix, b_matrix, driver='gels').solution

    output: List[float] = res.tolist()
    return output
def _get_perspective_coeffs ( startpoints : List [ List [ int ] ] , endpoints : List [ List [ int ] ] ) -> List [ float ] : a_matrix = torch . zeros ( 2 * len ( startpoints ) , 8 , dtype = torch . float ) for i , ( p1 , p2 ) in enumerate ( zip ( endpoints , startpoints ) ) : a_matrix [ 2 * i , : ] = torch . tensor ( [ p1 [ 0 ] , p1 [ 1 ] , 1 , 0 , 0 , 0 , - p2 [ 0 ] * p1 [ 0 ] , - p2 [ 0 ] * p1 [ 1 ] ] ) a_matrix [ 2 * i + 1 , : ] = torch . tensor ( [ 0 , 0 , 0 , p1 [ 0 ] , p1 [ 1 ] , 1 , - p2 [ 1 ] * p1 [ 0 ] , - p2 [ 1 ] * p1 [ 1 ] ] ) b_matrix = torch . tensor ( startpoints , dtype = torch . float ) . view ( 8 ) res = torch . linalg . lstsq ( a_matrix , b_matrix , driver = 'gels' ) . solution output : List [ float ] = res . tolist ( ) return output