code: def _intake_axis_for_nd_interp(axis, y_ref, nd):
      """Convert `axis` to its non-negative value and return after validation."""
      axis = ps.convert_to_shape_tensor(
          axis, dtype=tf.int32, name="axis"
      )
      axis = ps.non_negative_axis(axis, ps.rank(y_ref))
      tensorshape_util.assert_has_rank(axis.shape, 0)
      axis_ = tf.get_static_value(axis)
      y_ref_rank_ = tf.get_static_value(tf.rank(y_ref))
      if axis_ is not None and y_ref_rank_ is not None:
          if axis_ + nd > y_ref_rank_:
              raise ValueError(
                  "Since dims `[axis, axis + nd)` index the interpolation table, we "
                  "must have `axis + nd <= rank(y_ref)`.  Found: "
                  "`axis`: {},  rank(y_ref): {}, and inferred `nd` from trailing "
                  "dimensions of `x_ref_min` to be {}.".format(
                      axis_, y_ref_rank_, nd
                  )
              )
      return axis
  
imports: import itertools
  import numpy
  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 tensorshape_util
label_desc: Use image node_id 9 for calling a global function with example usage: _intake_axis_for_nd_interp(axis, y_ref, nd) and returns: axis