code: 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
  
imports: import math
  import numbers
  import sys
  import warnings
  from enum import Enum
  from typing import Any, List, Optional, Tuple, Union
  import numpy
  import torch
  from PIL import Image
  from torch import Tensor
  from ..utils import _log_api_usage_once
  from .None import _functional_pil, _functional_tensor
label_desc: Use image node_id 19 for calling a global function with example usage: _get_perspective_coeffs(startpoints, endpoints) and returns: output