code: def affine(
      img: Tensor,
      angle: float,
      translate: List[int],
      scale: float,
      shear: List[float],
      interpolation: InterpolationMode = InterpolationMode.NEAREST,
      fill: Optional[List[float]] = None,
      resample: Optional[int] = None,
      fillcolor: Optional[List[float]] = None,
      center: Optional[List[int]] = None,
  ) -> Tensor:
      """Apply affine transformation on the image keeping image center invariant.
      If the image is paddle Tensor, it is expected
      to have [..., H, W] shape, where ... means an arbitrary number of leading dimensions.
  
      Args:
          img (PIL Image or Tensor): image to transform.
          angle (number): rotation angle in degrees between -180 and 180, clockwise direction.
          translate (sequence of integers): horizontal and vertical translations (post-rotation translation)
          scale (float): overall scale
          shear (float or sequence): shear angle value in degrees between -180 to 180, clockwise direction.
              If a sequence is specified, the first value corresponds to a shear parallel to the x axis, while
              the second value corresponds to a shear parallel to the y axis.
          interpolation (InterpolationMode): Desired interpolation enum defined by
              :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
              If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
              For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still accepted,
              but deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
          fill (sequence or number, optional): Pixel fill value for the area outside the transformed
              image. If given a number, the value is used for all bands respectively.
  
              .. note::
                  In torchscript mode single int/float value is not supported, please use a sequence
                  of length 1: ``[value, ]``.
          fillcolor (sequence or number, optional):
              .. warning::
                  This parameter was deprecated in ``0.12`` and will be removed in ``0.14``. Please use ``fill`` instead.
          resample (int, optional):
              .. warning::
                  This parameter was deprecated in ``0.12`` and will be removed in ``0.14``. Please use ``interpolation``
                  instead.
          center (sequence, optional): Optional center of rotation. Origin is the upper left corner.
              Default is the center of the image.
  
      Returns:
          PIL Image or Tensor: Transformed image.
      """
  
      # Backward compatibility with integer value
      if isinstance(interpolation, int):
          warnings.warn(
              "Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
              "Please use InterpolationMode enum."
          )
          interpolation = _interpolation_modes_from_int(interpolation)
  
      if fillcolor is not None:
          warnings.warn(
              "The parameter 'fillcolor' is deprecated since 0.12 and will be removed in 0.14. "
              "Please use 'fill' instead."
          )
          fill = fillcolor
  
      if not isinstance(angle, (int, float)):
          raise TypeError("Argument angle should be int or float")
  
      if not isinstance(translate, (list, tuple)):
          raise TypeError("Argument translate should be a sequence")
  
      if len(translate) != 2:
          raise ValueError(
              "Argument translate should be a sequence of length 2"
          )
  
      if scale <= 0.0:
          raise ValueError("Argument scale should be positive")
  
      if not isinstance(shear, (numbers.Number, (list, tuple))):
          raise TypeError(
              "Shear should be either a single value or a sequence of two values"
          )
  
      if not isinstance(interpolation, InterpolationMode):
          raise TypeError(
              "Argument interpolation should be a InterpolationMode"
          )
  
      if isinstance(angle, int):
          angle = float(angle)
  
      if isinstance(translate, tuple):
          translate = list(translate)
  
      if isinstance(shear, numbers.Number):
          shear = [shear, 0.0]
  
      if isinstance(shear, tuple):
          shear = list(shear)
  
      if len(shear) == 1:
          shear = [shear[0], shear[0]]
  
      if len(shear) != 2:
          raise ValueError(
              f"Shear should be a sequence containing two values. Got {shear}"
          )
  
      if center is not None and not isinstance(center, (list, tuple)):
          raise TypeError("Argument center should be a sequence")
      center_f = [0.0, 0.0]
      if center is not None:
          _, height, width = img.shape[0], img.shape[1], img.shape[2]
          # Center values should be in pixel coordinates but translated such that (0, 0) corresponds to image center.
          center_f = [
              1.0 * (c - s * 0.5)
              for c, s in zip(center, [width, height])
          ]
  
      translate_f = [1.0 * t for t in translate]
      matrix = _get_inverse_affine_matrix(
          center_f, angle, translate_f, scale, shear
      )
      return affine_impl(
          img,
          matrix=matrix,
          interpolation=interpolation.value,
          fill=fill,
      )
  
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 14 for calling a global function with example usage: affine(img, angle, translate, scale, shear, interpolation, fill, resample, fillcolor, center) and returns: affine_impl