code: def _quantile_ureduce_func(
      a,
      q,
      axis=None,
      out=None,
      overwrite_input=False,
      interpolation="linear",
      keepdims=False,
  ):
      a = astensor(a)
      out = astensor(out) if out is not None else None
  
      if q.ndim == 0:
          # Do not allow 0-d arrays because following code fails for scalar
          zerod = True
          q = q[None]
      else:
          zerod = False
  
      # prepare a for partitioning
      if overwrite_input:
          if axis is None:
              ap = a.ravel()
          else:
              ap = a
      else:
          if axis is None:
              ap = a.flatten()
          else:
              ap = a.copy()
  
      if axis is None:
          axis = 0
  
      Nx = ap.shape[axis]
      indices = q * (Nx - 1)
  
      # round fractional indices according to interpolation method
      if interpolation == "lower":
          indices = np.floor(indices).astype(np.intp)
      elif interpolation == "higher":
          indices = np.ceil(indices).astype(np.intp)
      elif interpolation == "midpoint":
          indices = 0.5 * (np.floor(indices) + np.ceil(indices))
      elif interpolation == "nearest":
          indices = np.around(indices).astype(np.intp)
      else:
          assert interpolation == "linear"
          # keep index as fraction and interpolate
  
      n = np.array(False, dtype=bool)  # check for nan's flag
      if indices.dtype == np.intp:  # take the points along axis
          # Check if the array contains any nan's
          if np.issubdtype(a.dtype, np.inexact):
              indices = np.concatenate((indices, [-1]))
  
          ap.partition(indices, axis=axis, need_align=True)
          # ensure axis with q-th is first
          ap = moveaxis(ap, axis, 0)
          axis = 0
  
          # Check if the array contains any nan's
          if np.issubdtype(a.dtype, np.inexact):
              indices = indices[:-1]
              n = isnan(ap[-1:, ...])
  
          if zerod:
              indices = indices[0]
          r = take(ap, indices, axis=axis, out=out)
  
      else:  # weight the points above and below the indices
          indices_below = np.floor(indices).astype(np.intp)
          indices_above = indices_below + 1
          indices_above[indices_above > Nx - 1] = Nx - 1
  
          # Check if the array contains any nan's
          if np.issubdtype(a.dtype, np.inexact):
              indices_above = np.concatenate((indices_above, [-1]))
  
          weights_above = indices - indices_below
          weights_below = 1 - weights_above
  
          weights_shape = [1] * ap.ndim
          weights_shape[axis] = len(indices)
          weights_below.shape = weights_shape
          weights_above.shape = weights_shape
  
          ap.partition(
              np.concatenate((indices_below, indices_above)),
              axis=axis,
              need_align=True,
          )
  
          # ensure axis with q-th is first
          ap = moveaxis(ap, axis, 0)
          weights_below = np.moveaxis(weights_below, axis, 0)
          weights_above = np.moveaxis(weights_above, axis, 0)
          axis = 0
  
          # Check if the array contains any nan's
          if np.issubdtype(a.dtype, np.inexact):
              indices_above = indices_above[:-1]
              n = isnan(ap[-1:, ...])
  
          x1 = take(ap, indices_below, axis=axis) * weights_below
          x2 = take(ap, indices_above, axis=axis) * weights_above
  
          # ensure axis with q-th is first
          x1 = moveaxis(x1, axis, 0)
          x2 = moveaxis(x2, axis, 0)
  
          if zerod:
              x1 = x1.squeeze(0)
              x2 = x2.squeeze(0)
  
          if out is not None:
              r = add(x1, x2, out=out)
          else:
              r = add(x1, x2)
  
      if isinstance(n, TENSOR_TYPE):
          if zerod:
              if ap.ndim == 1:
                  r.data = where(
                      tensor_any(n), a.dtype.type(np.nan), r
                  ).data
                  if out is not None:
                      out.data = r.data
              else:
                  r[:] = where(
                      tensor_any(n),
                      where(n.squeeze(0), a.dtype.type(np.nan), r),
                      r,
                  )
          else:
              if r.ndim == 1:
                  r[:] = where(
                      tensor_any(n),
                      np.full(r.shape, a.dtype.type(np.nan)),
                      r,
                  )
              else:
                  r[:] = where(
                      tensor_any(n),
                      where(
                          n.repeat(q.size, 0), a.dtype.type(np.nan), r
                      ),
                      r,
                  )
  
      return r
  
imports: from collections.abc import Iterable
  import numpy
  from ...None import opcodes
  from ...core import ENTITY_TYPE, recursive_tile
  from ...core.context import get_context
  from ...serialization.serializables import KeyField, AnyField, StringField, BoolField
  from ...utils import has_unknown_shape
  from ..datasource import tensor
  from ..base import moveaxis, where
  from ..indexing import take
  from ..arithmetic import isnan, add
  from ..reduction import any
  from ..operands import TensorOperand, TensorOperandMixin
  from ..core import TENSOR_TYPE, TENSOR_CHUNK_TYPE, TensorOrder
  from ..utils import check_out_param
  from ..array_utils import as_same_device, device
  from .core import _ureduce
label_desc: Use image node_id 2 for calling a global function with example usage: _quantile_ureduce_func(a, q, axis, out, overwrite_input, interpolation, keepdims) and returns: r