code: def pad_distort_im_fn(x):
      """Zero pads an image to 40x40, and distort it.
  
      Examples
      ---------
      x = pad_distort_im_fn(X_train[0])
      print(x, x.shape, x.max())
      tl.vis.save_image(x, '_xd.png')
      tl.vis.save_image(X_train[0], '_x.png')
      """
      b = np.zeros((40, 40, 1), dtype=np.float32)
      o = int((40 - 28) / 2)
      b[o : o + 28, o : o + 28] = x
      x = b
      x = tl.prepro.rotation(
          x, rg=30, is_random=True, fill_mode="constant"
      )
      x = tl.prepro.shear(x, 0.05, is_random=True, fill_mode="constant")
      x = tl.prepro.shift(
          x, wrg=0.25, hrg=0.25, is_random=True, fill_mode="constant"
      )
      x = tl.prepro.zoom(x, zoom_range=(0.95, 1.05))
      return x
  
file_path: TensorLayer/examples/spatial_transformer_network/tutorial_spatial_transformer_network_static.py
imports: import time
  import numpy
  import tensorflow
  import tensorlayer
  from tensorlayer.layers import *
  from tensorlayer.models import Model
label_desc: Use image node_id 1 for calling a global function with example usage: pad_distort_im_fn(x) and returns: x