code: def th_nearest_interp2d(input_, coords):
      """
      2d nearest neighbor interpolation th.Tensor
      """
      # take clamp of coords so they're in the image bounds
      x = th.clamp(coords[:, :, 0], 0, input_.size(1) - 1).round()
      y = th.clamp(coords[:, :, 1], 0, input_.size(2) - 1).round()
  
      stride = th.LongTensor(input_.stride())
      x_ix = x.mul(stride[1]).long()
      y_ix = y.mul(stride[2]).long()
  
      input_flat = input_.view(input_.size(0), -1)
  
      mapped_vals = input_flat.gather(1, x_ix.add(y_ix))
  
      return mapped_vals.view_as(input_)
  
imports: import pickle
  import random
  from .optimizers import *
  from .callbacks import *
  import torch
  from pywick.callbacks import *
label_desc: Use image node_id 13 for calling a global function with example usage: th_nearest_interp2d(input_, coords) and returns: mapped_vals