code: def _get_inverse_affine_matrix(
      center: List[float],
      angle: float,
      translate: List[float],
      scale: float,
      shear: List[float],
      inverted: bool = True,
  ) -> List[float]:
      # Helper method to compute inverse matrix for affine transformation
  
      # Pillow requires inverse affine transformation matrix:
      # Affine matrix is : M = T * C * RotateScaleShear * C^-1
      #
      # where T is translation matrix: [1, 0, tx | 0, 1, ty | 0, 0, 1]
      #       C is translation matrix to keep center: [1, 0, cx | 0, 1, cy | 0, 0, 1]
      #       RotateScaleShear is rotation with scale and shear matrix
      #
      #       RotateScaleShear(a, s, (sx, sy)) =
      #       = R(a) * S(s) * SHy(sy) * SHx(sx)
      #       = [ s*cos(a - sy)/cos(sy), s*(-cos(a - sy)*tan(sx)/cos(sy) - sin(a)), 0 ]
      #         [ s*sin(a + sy)/cos(sy), s*(-sin(a - sy)*tan(sx)/cos(sy) + cos(a)), 0 ]
      #         [ 0                    , 0                                      , 1 ]
      # where R is a rotation matrix, S is a scaling matrix, and SHx and SHy are the shears:
      # SHx(s) = [1, -tan(s)] and SHy(s) = [1      , 0]
      #          [0, 1      ]              [-tan(s), 1]
      #
      # Thus, the inverse is M^-1 = C * RotateScaleShear^-1 * C^-1 * T^-1
  
      rot = math.radians(angle)
      sx = math.radians(shear[0])
      sy = math.radians(shear[1])
  
      cx, cy = center
      tx, ty = translate
  
      # RSS without scaling
      a = math.cos(rot - sy) / math.cos(sy)
      b = -math.cos(rot - sy) * math.tan(sx) / math.cos(sy) - math.sin(
          rot
      )
      c = math.sin(rot - sy) / math.cos(sy)
      d = -math.sin(rot - sy) * math.tan(sx) / math.cos(sy) + math.cos(
          rot
      )
  
      if inverted:
          # Inverted rotation matrix with scale and shear
          # det([[a, b], [c, d]]) == 1, since det(rotation) = 1 and det(shear) = 1
          matrix = [d, -b, 0.0, -c, a, 0.0]
          matrix = [x / scale for x in matrix]
          # Apply inverse of translation and of center translation: RSS^-1 * C^-1 * T^-1
          matrix[2] += matrix[0] * (-cx - tx) + matrix[1] * (-cy - ty)
          matrix[5] += matrix[3] * (-cx - tx) + matrix[4] * (-cy - ty)
          # Apply center translation: C * RSS^-1 * C^-1 * T^-1
          matrix[2] += cx
          matrix[5] += cy
      else:
          matrix = [a, b, 0.0, c, d, 0.0]
          matrix = [x * scale for x in matrix]
          # Apply inverse of center translation: RSS * C^-1
          matrix[2] += matrix[0] * (-cx) + matrix[1] * (-cy)
          matrix[5] += matrix[3] * (-cx) + matrix[4] * (-cy)
          # Apply translation and center : T * C * RSS * C^-1
          matrix[2] += cx + tx
          matrix[5] += cy + ty
  
      return matrix
  
imports: import math
  import numbers
  import warnings
  from enum import Enum
  from typing import Any
  from typing import Dict
  from typing import List
  from typing import Optional
  from typing import Sequence
  from typing import Tuple
  from typing import Union
  import paddle
  import paddle.nn
  from paddle import Tensor
  from paddle.nn import functional
  from paddle.nn.functional import grid_sample
  from paddle.vision import transforms
label_desc: Use image node_id 13 for calling a global function with example usage: _get_inverse_affine_matrix(center, angle, translate, scale, shear, inverted) and returns: matrix