code: def invert_affine_transform(matrix: Tensor) -> Tensor:
      r"""Invert an affine transformation.
  
      The function computes an inverse affine transformation represented by
      2x3 matrix:
  
      .. math::
          \begin{bmatrix}
              a_{11} & a_{12} & b_{1} \\
              a_{21} & a_{22} & b_{2} \\
          \end{bmatrix}
  
      The result is also a 2x3 matrix of the same type as M.
  
      Args:
          matrix: original affine transform. The tensor must be
            in the shape of :math:`(B, 2, 3)`.
  
      Return:
          the reverse affine transform with shape :math:`(B, 2, 3)`.
  
      .. note::
          This function is often used in conjunction with :func:`warp_affine`.
      """
      if not isinstance(matrix, Tensor):
          raise TypeError(
              f"Input matrix type is not a Tensor. Got {type(matrix)}"
          )
  
      if not (len(matrix.shape) == 3 and matrix.shape[-2:] == (2, 3)):
          raise ValueError(
              f"Input matrix must be a Bx2x3 tensor. Got {matrix.shape}"
          )
  
      matrix_tmp: Tensor = convert_affinematrix_to_homography(matrix)
      matrix_inv: Tensor = _torch_inverse_cast(matrix_tmp)
  
      return matrix_inv[..., :2, :3]
  
imports: from __future__ import annotations
  from typing import Optional
  import torch
  import torch.nn.functional
  from kornia.core import Tensor, concatenate, ones, ones_like, stack, tan, tensor, zeros
  from kornia.core.check import KORNIA_CHECK, KORNIA_CHECK_SHAPE
  from kornia.geometry.conversions import angle_to_rotation_matrix, axis_angle_to_rotation_matrix, convert_affinematrix_to_homography, convert_affinematrix_to_homography3d, deg2rad, normalize_homography, normalize_homography3d, normalize_pixel_coordinates
  from kornia.geometry.linalg import transform_points
  from kornia.utils import create_meshgrid, create_meshgrid3d, eye_like
  from kornia.utils.helpers import _torch_inverse_cast, _torch_solve_cast
label_desc: Use image node_id 9 for calling a global function with example usage: invert_affine_transform(matrix) and returns: matrix_inv