code: def np_sample(img, coords):
      # a numpy implementation of ImageSample layer
      coords = np.maximum(coords, 0)
      coords = np.minimum(
          coords, np.array([img.shape[0] - 1, img.shape[1] - 1])
      )
  
      lcoor = np.floor(coords).astype("int32")
      ucoor = lcoor + 1
      ucoor = np.minimum(
          ucoor, np.array([img.shape[0] - 1, img.shape[1] - 1])
      )
      diff = coords - lcoor
      neg_diff = 1.0 - diff
  
      lcoory, lcoorx = np.split(lcoor, 2, axis=2)
      ucoory, ucoorx = np.split(ucoor, 2, axis=2)
      diff = np.repeat(diff, 3, 2).reshape(
          (diff.shape[0], diff.shape[1], 2, 3)
      )
      neg_diff = np.repeat(neg_diff, 3, 2).reshape(
          (diff.shape[0], diff.shape[1], 2, 3)
      )
      diffy, diffx = np.split(diff, 2, axis=2)
      ndiffy, ndiffx = np.split(neg_diff, 2, axis=2)
  
      ret = (
          img[lcoory, lcoorx, :] * ndiffx * ndiffy
          + img[ucoory, ucoorx, :] * diffx * diffy
          + img[lcoory, ucoorx, :] * ndiffy * diffx
          + img[ucoory, lcoorx, :] * diffy * ndiffx
      )
      return ret[:, :, 0, :]
  
file_path: tensorpack/tensorpack/dataflow/imgaug/deform.py
imports: import numpy
  from ...utils import logger
  from .base import ImageAugmentor
  from .transform import TransformFactory
label_desc: Use image node_id 1 for calling a global function with example usage: np_sample(img, coords) and returns: ret