code: def matrices_to_flat_transforms(
      transform_matrices: TensorLike, name: Optional[str] = None
  ) -> tf.Tensor:
      """Converts affine matrices to projective transforms.
  
      Note that we expect matrices that map output coordinates to input
      coordinates. To convert forward transformation matrices,
      call `tf.linalg.inv` on the matrices and use the result here.
  
      Args:
        transform_matrices: One or more affine transformation matrices, for the
          reverse transformation in homogeneous coordinates. Shape `(3, 3)` or
          `(N, 3, 3)`.
        name: The name for the op.
  
      Returns:
        2D tensor of flat transforms with shape `(N, 8)`, which may be passed
        into `transform` op.
  
      Raises:
        ValueError: If `transform_matrices` have an invalid shape.
      """
      with tf.name_scope(name or "matrices_to_flat_transforms"):
          transform_matrices = tf.convert_to_tensor(
              transform_matrices, name="transform_matrices"
          )
          if transform_matrices.shape.ndims not in (2, 3):
              raise ValueError(
                  "Matrices should be 2D or 3D, got: %s"
                  % transform_matrices
              )
          # Flatten each matrix.
          transforms = tf.reshape(
              transform_matrices, tf.constant([-1, 9])
          )
          # Divide each matrix by the last entry (normally 1).
          transforms /= transforms[:, 8:9]
          return transforms[:, :8]
  
file_path: addons/tensorflow_addons/image/transform_ops.py
imports: import tensorflow
  from tensorflow_addons.image import utils
  from tensorflow_addons.utils.types import TensorLike
  from tensorflow_addons.image.utils import wrap, unwrap
  from typing import Optional
label_desc: Use image node_id 4 for calling a global function with example usage: matrices_to_flat_transforms(transform_matrices, name) and returns: transforms