code: def quantile_divisions(df, by, npartitions):
      qn = np.linspace(0.0, 1.0, npartitions + 1).tolist()
      divisions = _approximate_quantile(df[by], qn).compute()
      columns = divisions.columns
  
      # TODO: Make sure divisions are correct for all dtypes..
      if (
          len(columns) == 1
          and df[columns[0]].dtype != "object"
          and not is_categorical_dtype(df[columns[0]].dtype)
      ):
          dtype = df[columns[0]].dtype
          divisions = divisions[columns[0]].astype("int64")
          divisions.iloc[-1] += 1
          divisions = sorted(
              divisions.drop_duplicates()
              .astype(dtype)
              .to_arrow()
              .tolist(),
              key=lambda x: (x is None, x),
          )
      else:
          for col in columns:
              dtype = df[col].dtype
              if dtype != "object":
                  divisions[col] = divisions[col].astype("int64")
                  divisions[col].iloc[-1] += 1
                  divisions[col] = divisions[col].astype(dtype)
              else:
                  if last := divisions[col].iloc[-1]:
                      val = chr(ord(last[0]) + 1)
                  else:
                      val = "this string intentionally left empty"  # any but ""
                  divisions[col].iloc[-1] = val
          divisions = divisions.drop_duplicates().sort_index()
      return divisions
  
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 7 for calling a global function with example usage: quantile_divisions(df, by, npartitions) and returns: divisions