code: def _approximate_quantile(df, q):
      """Approximate quantiles of DataFrame or Series.
      [NOTE: Same logic as dask.dataframe Series quantile]
      """
      # current implementation needs q to be sorted so
      # sort if array-like, otherwise leave it alone
      q_ndarray = np.array(q)
      if q_ndarray.ndim > 0:
          q_ndarray.sort(kind="mergesort")
          q = q_ndarray
  
      # Lets assume we are dealing with a DataFrame throughout
      if isinstance(df, (Series, Index)):
          df = df.to_frame()
      assert isinstance(df, DataFrame)
      final_type = df._meta._constructor
  
      # Create metadata
      meta = df._meta_nonempty.quantile(q=q, method="table")
  
      # Define final action (create df with quantiles as index)
      def finalize_tsk(tsk):
          return (final_type, tsk)
  
      return_type = df.__class__
  
      # pandas/cudf uses quantile in [0, 1]
      # numpy / cupy uses [0, 100]
      qs = np.asarray(q)
      token = tokenize(df, qs)
  
      if len(qs) == 0:
          name = "quantiles-" + token
          empty_index = gd.Index([], dtype=float)
          return Series(
              {
                  (name, 0): final_type(
                      {col: [] for col in df.columns},
                      name=df.name,
                      index=empty_index,
                  )
              },
              name,
              df._meta,
              [None, None],
          )
      else:
          new_divisions = [np.min(q), np.max(q)]
  
      name = "quantiles-1-" + token
      val_dsk = {
          (name, i): (_quantile, key, qs)
          for i, key in enumerate(df.__dask_keys__())
      }
  
      name2 = "quantiles-2-" + token
      merge_dsk = {
          (name2, 0): finalize_tsk(
              (
                  merge_quantiles,
                  qs,
                  [qs] * df.npartitions,
                  sorted(val_dsk),
              )
          )
      }
      dsk = toolz.merge(val_dsk, merge_dsk)
      graph = HighLevelGraph.from_collections(
          name2, dsk, dependencies=[df]
      )
      df = return_type(graph, name2, meta, new_divisions)
  
      def set_quantile_index(df):
          df.index = q
          return df
  
      df = df.map_partitions(set_quantile_index, meta=meta)
      return df
  
imports: import warnings
  from collections.abc import Iterator
  from functools import wraps
  import cupy
  import numpy
  import tlz
  from dask import config
  from dask.base import tokenize
  from dask.dataframe import methods
  from dask.dataframe.core import DataFrame, Index, Series
  from dask.dataframe.shuffle import rearrange_by_column
  from dask.highlevelgraph import HighLevelGraph
  from dask.utils import M
  import cudf
  from cudf.api.types import is_categorical_dtype
  from cudf.utils.nvtx_annotation import _dask_cudf_nvtx_annotate
label_desc: Use image node_id 6 for calling a global function with example usage: _approximate_quantile(df, q) and returns: df, final_type,  tsk, Series, df