code: def batch_interp_regular_nd_grid_fn(self):
      def regular_to_rectilinear_interp(
          x,
          x_ref_min,
          x_ref_max,
          y_ref,
          axis,
          fill_value="constant_extension",
      ):
          """Call rectilinear interpolation on args from regular grid interp."""
          dtype = dtype_util.common_dtype(
              [x, x_ref_min, x_ref_max, y_ref], dtype_hint=tf.float32
          )
          x = tf.convert_to_tensor(x, dtype=dtype)
  
          y_ref = tf.convert_to_tensor(y_ref, dtype=dtype)
          x_ref_min = tf.convert_to_tensor(x_ref_min, dtype=dtype)
          x_ref_max = tf.convert_to_tensor(x_ref_max, dtype=dtype)
          nd = tf.compat.dimension_value(x_ref_min.shape[-1])
          pos_axis = ps.non_negative_axis(axis, ps.rank(y_ref))
          ny = tf.cast(
              ps.shape_slice(y_ref, np.s_[pos_axis : pos_axis + nd]),
              tf.int32,
          )
  
          x_grid_points = []
          for k in range(nd):
              x_grid_points.append(
                  tf.linspace(
                      x_ref_min[..., k],
                      x_ref_max[..., k],
                      num=ny[k],
                      axis=-1,
                  )
              )
  
          return interpolation.batch_interp_rectilinear_nd_grid(
              x,
              tuple(x_grid_points),
              y_ref,
              axis,
              fill_value=fill_value,
          )
  
      return regular_to_rectilinear_interp
  
imports: import numpy
  from scipy import interpolate
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.math import interpolation
label_desc: Use image node_id 1 for calling the BatchInterpRectilinearNDGridTest obj's underlying member method code with example usage: obj.batch_interp_regular_nd_grid_fn() and returns: regular_to_rectilinear_interp, interpolation