code: def elastic_transform_approx(
      img: np.ndarray,
      alpha: float,
      sigma: float,
      alpha_affine: float,
      interpolation: int = cv2.INTER_LINEAR,
      border_mode: int = cv2.BORDER_REFLECT_101,
      value: Optional[ImageColorType] = None,
      random_state: Optional[np.random.RandomState] = None,
  ) -> np.ndarray:
      """Elastic deformation of images as described in [Simard2003]_ (with modifications for speed).
      Based on https://gist.github.com/ernestum/601cdf56d2b424757de5
  
      .. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
           Convolutional Neural Networks applied to Visual Document Analysis", in
           Proc. of the International Conference on Document Analysis and
           Recognition, 2003.
      """
      height, width = img.shape[:2]
  
      # Random affine
      center_square = np.array((height, width), dtype=np.float32) // 2
      square_size = min((height, width)) // 3
      alpha = float(alpha)
      sigma = float(sigma)
      alpha_affine = float(alpha_affine)
  
      pts1 = np.array(
          [
              center_square + square_size,
              [
                  center_square[0] + square_size,
                  center_square[1] - square_size,
              ],
              center_square - square_size,
          ],
          dtype=np.float32,
      )
      pts2 = pts1 + random_utils.uniform(
          -alpha_affine,
          alpha_affine,
          size=pts1.shape,
          random_state=random_state,
      ).astype(np.float32)
      matrix = cv2.getAffineTransform(pts1, pts2)
  
      warp_fn = _maybe_process_in_chunks(
          cv2.warpAffine,
          M=matrix,
          dsize=(width, height),
          flags=interpolation,
          borderMode=border_mode,
          borderValue=value,
      )
      img = warp_fn(img)
  
      dx = (
          random_utils.rand(
              height, width, random_state=random_state
          ).astype(np.float32)
          * 2
          - 1
      )
      cv2.GaussianBlur(dx, (17, 17), sigma, dst=dx)
      dx *= alpha
  
      dy = (
          random_utils.rand(
              height, width, random_state=random_state
          ).astype(np.float32)
          * 2
          - 1
      )
      cv2.GaussianBlur(dy, (17, 17), sigma, dst=dy)
      dy *= alpha
  
      x, y = np.meshgrid(np.arange(width), np.arange(height))
  
      map_x = np.float32(x + dx)
      map_y = np.float32(y + dy)
  
      remap_fn = _maybe_process_in_chunks(
          cv2.remap,
          map1=map_x,
          map2=map_y,
          interpolation=interpolation,
          borderMode=border_mode,
          borderValue=value,
      )
      return remap_fn(img)
  
imports: import math
  from typing import List, Optional, Sequence, Tuple, Union
  import cv2
  import numpy
  import skimage.transform
  from scipy.ndimage import gaussian_filter
  from albumentations.augmentations.utils import _maybe_process_in_chunks, angle_2pi_range, clipped, preserve_channel_dim, preserve_shape
  from ...None import random_utils
  from ...core.bbox_utils import denormalize_bbox, normalize_bbox
  from ...core.transforms_interface import BoxInternalType, FillValueType, ImageColorType, KeypointInternalType
label_desc: Use image node_id 51 for calling a global function with example usage: elastic_transform_approx(img, alpha, sigma, alpha_affine, interpolation, border_mode, value, random_state) and returns: remap_fn