class_docstr: Random affine transform of the image w.r.t to the image center.
  Transformations involve:
  
  - Translation ("move" image on the x-/y-axis)
  - Rotation
  - Scaling ("zoom" in/out)
  - Shear (move one side of the image, turning a square into a trapezoid)
code: def get_transform(self, img):
      if self.scale is not None:
          scale = self._rand_range(self.scale[0], self.scale[1])
      else:
          scale = 1.0
  
      if self.translate_frac is not None:
          max_dx = self.translate_frac[0] * img.shape[1]
          max_dy = self.translate_frac[1] * img.shape[0]
          dx = np.round(self._rand_range(-max_dx, max_dx))
          dy = np.round(self._rand_range(-max_dy, max_dy))
      else:
          dx = 0
          dy = 0
  
      if self.shear > 0.0:
          shear = self._rand_range(-self.shear, self.shear)
          sin_shear = math.sin(math.radians(shear))
          cos_shear = math.cos(math.radians(shear))
      else:
          sin_shear = 0.0
          cos_shear = 1.0
  
      center = (img.shape[1::-1] * np.array((0.5, 0.5))) - 0.5
      deg = self._rand_range(-self.rotate_max_deg, self.rotate_max_deg)
  
      transform_matrix = cv2.getRotationMatrix2D(
          tuple(center), deg, scale
      )
  
      # Apply shear :
      if self.shear > 0.0:
          m00 = transform_matrix[0, 0]
          m01 = transform_matrix[0, 1]
          m10 = transform_matrix[1, 0]
          m11 = transform_matrix[1, 1]
          transform_matrix[0, 1] = m01 * cos_shear + m00 * sin_shear
          transform_matrix[1, 1] = m11 * cos_shear + m10 * sin_shear
          # Add correction term to keep the center unchanged
          tx = (
              center[0] * (1.0 - m00)
              - center[1] * transform_matrix[0, 1]
          )
          ty = -center[0] * m10 + center[1] * (
              1.0 - transform_matrix[1, 1]
          )
          transform_matrix[0, 2] = tx
          transform_matrix[1, 2] = ty
  
      # Apply shift :
      transform_matrix[0, 2] += dx
      transform_matrix[1, 2] += dy
      return WarpAffineTransform(
          transform_matrix,
          img.shape[1::-1],
          self.interp,
          self.border,
          self.border_value,
      )
  
imports: import math
  import numpy
  import cv2
  from .base import ImageAugmentor
  from .transform import WarpAffineTransform, CropTransform, TransformList
label_desc: Use image node_id 2 for calling the Affine obj's underlying member method code with example usage: obj.get_transform(img) and returns: WarpAffineTransform