code: def quantile(x, q, interpolation_method="fraction"):
      """
      Compute sample quantile or quantiles of the input array. For example, q=0.5
      computes the median.
  
      The `interpolation_method` parameter supports three values, namely
      `fraction` (default), `lower` and `higher`. Interpolation is done only,
      if the desired quantile lies between two data points `i` and `j`. For
      `fraction`, the result is an interpolated value between `i` and `j`;
      for `lower`, the result is `i`, for `higher` the result is `j`.
  
      Parameters
      ----------
      x : ndarray
          Values from which to extract score.
      q : scalar or array
          Percentile at which to extract score.
      interpolation_method : {'fraction', 'lower', 'higher'}, optional
          This optional parameter specifies the interpolation method to use,
          when the desired quantile lies between two data points `i` and `j`:
  
          - fraction: `i + (j - i)*fraction`, where `fraction` is the
                      fractional part of the index surrounded by `i` and `j`.
          -lower: `i`.
          - higher: `j`.
  
      Returns
      -------
      score : float
          Score at percentile.
  
      Examples
      --------
      >>> from scipy import stats
      >>> a = np.arange(100)
      >>> stats.scoreatpercentile(a, 50)
      49.5
  
      """
      x = np.asarray(x)
      mask = isna(x)
  
      x = x[~mask]
  
      values = np.sort(x)
  
      def _interpolate(a, b, fraction):
          """Returns the point at the given fraction between a and b, where
          'fraction' must be between 0 and 1.
          """
          return a + (b - a) * fraction
  
      def _get_score(at):
          if len(values) == 0:
              return np.nan
  
          idx = at * (len(values) - 1)
          if idx % 1 == 0:
              score = values[int(idx)]
          else:
              if interpolation_method == "fraction":
                  score = _interpolate(
                      values[int(idx)], values[int(idx) + 1], idx % 1
                  )
              elif interpolation_method == "lower":
                  score = values[np.floor(idx)]
              elif interpolation_method == "higher":
                  score = values[np.ceil(idx)]
              else:
                  raise ValueError(
                      "interpolation_method can only be 'fraction' "
                      ", 'lower' or 'higher'"
                  )
  
          return score
  
      if is_scalar(q):
          return _get_score(q)
      else:
          q = np.asarray(q, np.float64)
          return algos.arrmap_float64(q, _get_score)
  
imports: from __future__ import division
  from textwrap import dedent
  from warnings import catch_warnings, simplefilter, warn
  import numpy
  from pandas._libs import algos, hashtable, lib
  from pandas._libs.tslib import iNaT
  from pandas.util._decorators import Appender, Substitution, deprecate_kwarg
  from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike, maybe_promote
  from pandas.core.dtypes.common import ensure_float64, ensure_int64, ensure_object, ensure_platform_int, ensure_uint64, is_array_like, is_bool_dtype, is_categorical_dtype, is_complex_dtype, is_datetime64_any_dtype, is_datetime64tz_dtype, is_datetimelike, is_extension_array_dtype, is_float_dtype, is_integer_dtype, is_interval_dtype, is_list_like, is_numeric_dtype, is_object_dtype, is_period_dtype, is_scalar, is_signed_integer_dtype, is_sparse, is_timedelta64_dtype, is_unsigned_integer_dtype, needs_i8_conversion
  from pandas.core.dtypes.generic import ABCIndex, ABCIndexClass, ABCSeries
  from pandas.core.dtypes.missing import isna, na_value_for_dtype
  from pandas.core import common
label_desc: Use image node_id 17 for calling a global function with example usage: quantile(x, q, interpolation_method) and returns: unknown, score, _get_score, algos, np