code: def get_affine_transform(
      center,
      scale,
      rot,
      output_size,
      shift=np.array([0, 0], dtype=np.float32),
      inv=0,
  ):
      """Get affine transform matrix given center, scale and rotation.
  
      Parameters
      ----------
      center : tuple of float
          Center point.
      scale : float
          Scaling factor.
      rot : float
          Rotation degree.
      output_size : tuple of int
          (width, height) of the output size.
      shift : float
          Shift factor.
      inv : bool
          Whether inverse the computation.
  
      Returns
      -------
      numpy.ndarray
          Affine matrix.
  
      """
      from ...utils.filesystem import try_import_cv2
  
      cv2 = try_import_cv2()
      if not isinstance(scale, np.ndarray) and not isinstance(
          scale, list
      ):
          scale = np.array([scale, scale], dtype=np.float32)
  
      scale_tmp = scale
      src_w = scale_tmp[0]
      dst_w = output_size[0]
      dst_h = output_size[1]
  
      rot_rad = np.pi * rot / 180
      src_dir = get_rot_dir([0, src_w * -0.5], rot_rad)
      dst_dir = np.array([0, dst_w * -0.5], np.float32)
  
      src = np.zeros((3, 2), dtype=np.float32)
      dst = np.zeros((3, 2), dtype=np.float32)
      src[0, :] = center + scale_tmp * shift
      src[1, :] = center + src_dir + scale_tmp * shift
      dst[0, :] = [dst_w * 0.5, dst_h * 0.5]
      dst[1, :] = (
          np.array([dst_w * 0.5, dst_h * 0.5], np.float32) + dst_dir
      )
  
      src[2:, :] = get_3rd_point(src[0, :], src[1, :])
      dst[2:, :] = get_3rd_point(dst[0, :], dst[1, :])
  
      if inv:
          trans = cv2.getAffineTransform(
              np.float32(dst), np.float32(src)
          )
      else:
          trans = cv2.getAffineTransform(
              np.float32(src), np.float32(dst)
          )
      return trans
  
file_path: gluon-cv/gluoncv/data/transforms/bbox.py
imports: from __future__ import division
  import numpy
label_desc: Use image node_id 8 for calling a global function with example usage: get_affine_transform(center, scale, rot, output_size, shift, inv) and returns: trans