code: def perspective_transformation(
      M: np.ndarray, points: np.ndarray, is_inv: bool = False
  ) -> np.ndarray:
      if is_inv:
          M = np.linalg.inv(M)
  
      src_mid = np.hstack(
          [points, np.ones((points.shape[0], 1))]
      ).T  # 3x4
      dst_mid = np.matmul(M, src_mid)
  
      dst = (dst_mid / dst_mid[-1]).T[:, :2]  # 4x2
  
      return dst
  
file_path: layout-parser/src/layoutparser/elements/utils.py
imports: from typing import List, Union, Dict, Dict, Any, Optional, Tuple
  import numpy
  from PIL import Image
label_desc: Use image node_id 3 for calling a global function with example usage: perspective_transformation(M, points, is_inv) and returns: dst