code: def percentile(
      a, q, method="linear", internal_method="default", **kwargs
  ):
      """Approximate percentile of 1-D array
  
      Parameters
      ----------
      a : Array
      q : array_like of float
          Percentile or sequence of percentiles to compute, which must be between
          0 and 100 inclusive.
      method : {'linear', 'lower', 'higher', 'midpoint', 'nearest'}, optional
          The interpolation method to use when the desired percentile lies
          between two data points ``i < j``. Only valid for ``method='dask'``.
  
          - 'linear': ``i + (j - i) * fraction``, where ``fraction``
            is the fractional part of the index surrounded by ``i``
            and ``j``.
          - 'lower': ``i``.
          - 'higher': ``j``.
          - 'nearest': ``i`` or ``j``, whichever is nearest.
          - 'midpoint': ``(i + j) / 2``.
  
          .. versionchanged:: 2022.1.0
              This argument was previously called "interpolation"
  
      internal_method : {'default', 'dask', 'tdigest'}, optional
          What internal method to use. By default will use dask's internal custom
          algorithm (``'dask'``).  If set to ``'tdigest'`` will use tdigest for
          floats and ints and fallback to the ``'dask'`` otherwise.
  
          .. versionchanged:: 2022.1.0
              This argument was previously called “method”.
  
      interpolation : str, optional
          Deprecated name for the method keyword argument.
  
          .. deprecated:: 2022.1.0
  
      See Also
      --------
      numpy.percentile : Numpy's equivalent Percentile function
      """
      from dask.array.dispatch import percentile_lookup as _percentile
      from dask.array.utils import array_safe, meta_from_array
  
      allowed_internal_methods = ["default", "dask", "tdigest"]
  
      if method in allowed_internal_methods:
          warnings.warn(
              "In Dask 2022.1.0, the `method=` argument was renamed to `internal_method=`",
              FutureWarning,
          )
          internal_method = method
  
      if "interpolation" in kwargs:
          if _numpy_122:
              warnings.warn(
                  "In Dask 2022.1.0, the `interpolation=` argument to percentile was renamed to "
                  "`method= ` ",
                  FutureWarning,
              )
          method = kwargs.pop("interpolation")
  
      if kwargs:
          raise TypeError(
              f"percentile() got an unexpected keyword argument {kwargs.keys()}"
          )
  
      if not a.ndim == 1:
          raise NotImplementedError(
              "Percentiles only implemented for 1-d arrays"
          )
      if isinstance(q, Number):
          q = [q]
      q = array_safe(q, like=meta_from_array(a))
      token = tokenize(a, q, method)
  
      dtype = a.dtype
      if np.issubdtype(dtype, np.integer):
          dtype = (
              array_safe([], dtype=dtype, like=meta_from_array(a)) / 0.5
          ).dtype
      meta = meta_from_array(a, dtype=dtype)
  
      if internal_method not in allowed_internal_methods:
          raise ValueError(
              f"`internal_method=` must be one of {allowed_internal_methods}"
          )
  
      # Allow using t-digest if method is allowed and dtype is of floating or integer type
      if (
          internal_method == "tdigest"
          and method == "linear"
          and (
              np.issubdtype(dtype, np.floating)
              or np.issubdtype(dtype, np.integer)
          )
      ):
          from dask.utils import import_required
  
          import_required(
              "crick",
              "crick is a required dependency for using the t-digest method.",
          )
  
          name = "percentile_tdigest_chunk-" + token
          dsk = {
              (name, i): (_tdigest_chunk, key)
              for i, key in enumerate(a.__dask_keys__())
          }
  
          name2 = "percentile_tdigest-" + token
  
          dsk2 = {
              (name2, 0): (_percentiles_from_tdigest, q, sorted(dsk))
          }
  
      # Otherwise use the custom percentile algorithm
      else:
          # Add 0 and 100 during calculation for more robust behavior (hopefully)
          calc_q = np.pad(q, 1, mode="constant")
          calc_q[-1] = 100
          name = "percentile_chunk-" + token
          dsk = {
              (name, i): (_percentile, key, calc_q, method)
              for i, key in enumerate(a.__dask_keys__())
          }
  
          name2 = "percentile-" + token
          dsk2 = {
              (name2, 0): (
                  merge_percentiles,
                  q,
                  [calc_q] * len(a.chunks[0]),
                  sorted(dsk),
                  method,
              )
          }
  
      dsk = merge(dsk, dsk2)
      graph = HighLevelGraph.from_collections(
          name2, dsk, dependencies=[a]
      )
      return Array(graph, name2, chunks=((len(q),),), meta=meta)
  
file_path: dask/dask/array/percentile.py
imports: from __future__ import annotations
  import warnings
  from collections.abc import Iterator
  from functools import wraps
  from numbers import Number
  import numpy
  from tlz import merge
  from dask.array.core import Array
  from dask.array.numpy_compat import _numpy_122
  from dask.array.numpy_compat import percentile
  from dask.base import tokenize
  from dask.highlevelgraph import HighLevelGraph
label_desc: Use image node_id 4 for calling a global function with example usage: percentile(a, q, method, internal_method) and returns: Array