code: def _fixed_ref_map_coordinates(
      input, coordinates, order, mode, cval=0.0
  ):
      # SciPy's implementation of map_coordinates handles boundaries incorrectly,
      # unless mode='reflect'. For order=1, this only affects interpolation outside
      # the bounds of the original array.
      # https://github.com/scipy/scipy/issues/2640
      assert order <= 1
      padding = [
          (
              max(-np.floor(c.min()).astype(int) + 1, 0),
              max(np.ceil(c.max()).astype(int) + 1 - size, 0),
          )
          for c, size in zip(coordinates, input.shape)
      ]
      shifted_coords = [c + p[0] for p, c in zip(padding, coordinates)]
      pad_mode = {
          "nearest": "edge",
          "mirror": "reflect",
          "reflect": "symmetric",
      }.get(mode, mode)
      if mode == "constant":
          padded = np.pad(
              input, padding, mode=pad_mode, constant_values=cval
          )
      else:
          padded = np.pad(input, padding, mode=pad_mode)
      result = osp_ndimage.map_coordinates(
          padded, shifted_coords, order=order, mode=mode, cval=cval
      )
      return result
  
file_path: jax/tests/scipy_ndimage_test.py
imports: from functools import partial
  import math
  import numpy
  from absl.testing import absltest
  import scipy.ndimage
  from jax import grad
  from jax._src import test_util
  from jax import dtypes
  from jax.scipy import ndimage
  from jax import config
label_desc: Use image node_id 1 for calling a global function with example usage: _fixed_ref_map_coordinates(input, coordinates, order, mode, cval) and returns: result