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 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 29 for calling a global function with example usage: _get_inverse_affine_matrix(center, angle, translate, scale, shear, inverted) and returns: matrix