code: def sorted_division_locations(seq, npartitions=None, chunksize=None):
      """Find division locations and values in sorted list
  
      Examples
      --------
  
      >>> L = ['A', 'B', 'C', 'D', 'E', 'F']
      >>> sorted_division_locations(L, chunksize=2)
      (['A', 'C', 'E', 'F'], [0, 2, 4, 6])
  
      >>> sorted_division_locations(L, chunksize=3)
      (['A', 'D', 'F'], [0, 3, 6])
  
      >>> L = ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'C']
      >>> sorted_division_locations(L, chunksize=3)
      (['A', 'B', 'C', 'C'], [0, 4, 7, 8])
  
      >>> sorted_division_locations(L, chunksize=2)
      (['A', 'B', 'C', 'C'], [0, 4, 7, 8])
  
      >>> sorted_division_locations(['A'], chunksize=2)
      (['A', 'A'], [0, 1])
      """
      if (npartitions is None) == (chunksize is None):
          raise ValueError(
              "Exactly one of npartitions and chunksize must be specified."
          )
  
      # Find unique-offset array (if duplicates exist).
      # Note that np.unique(seq) should work in all cases
      # for newer versions of numpy/pandas
      seq_unique = (
          seq.unique() if hasattr(seq, "unique") else np.unique(seq)
      )
      duplicates = len(seq_unique) < len(seq)
      enforce_exact = False
      if duplicates:
          offsets = (
              # Avoid numpy conversion (necessary for dask-cudf)
              seq.searchsorted(seq_unique, side="left")
              if hasattr(seq, "searchsorted")
              else np.array(seq).searchsorted(seq_unique, side="left")
          )
          enforce_exact = npartitions and len(offsets) >= npartitions
      else:
          offsets = seq_unique = None
  
      # Define chunksize and residual so that
      # npartitions can be exactly satisfied
      # when duplicates is False
      residual = 0
      subtract_drift = False
      if npartitions:
          chunksize = len(seq) // npartitions
          residual = len(seq) % npartitions
          subtract_drift = True
  
      def chunksizes(ind):
          # Helper function to satisfy npartitions
          return chunksize + int(ind < residual)
  
      # Always start with 0th item in seqarr,
      # and then try to take chunksize steps
      # along the seqarr array
      divisions = [seq[0]]
      locations = [0]
      i = chunksizes(0)
      ind = None  # ind cache (sometimes avoids nonzero call)
      drift = 0  # accumulated drift away from ideal chunksizes
      divs_remain = (
          npartitions - len(divisions) if enforce_exact else None
      )
      while i < len(seq):
          # Map current position selection (i)
          # to the corresponding division value (div)
          div = seq[i]
          # pos is the position of the first occurance of
          # div (which is i when seq has no duplicates)
          if duplicates:
              # Note: cupy requires casts to `int` below
              if ind is None:
                  ind = int((seq_unique == seq[i]).nonzero()[0][0])
              if enforce_exact:
                  # Avoid "over-stepping" too many unique
                  # values when npartitions is approximately
                  # equal to len(offsets)
                  offs_remain = len(offsets) - ind
                  if divs_remain > offs_remain:
                      ind -= divs_remain - offs_remain
                      i = offsets[ind]
                      div = seq[i]
              pos = int(offsets[ind])
          else:
              pos = i
          if div <= divisions[-1]:
              # pos overlaps with divisions.
              # Try the next element on the following pass
              if duplicates:
                  ind += 1
                  # Note: cupy requires cast to `int`
                  i = (
                      int(offsets[ind])
                      if ind < len(offsets)
                      else len(seq)
                  )
              else:
                  i += 1
          else:
              # pos does not overlap with divisions.
              # Append candidate pos/div combination, and
              # take another chunksize step
              if subtract_drift:
                  # Only subtract drift when user specified npartitions
                  drift = drift + (
                      (pos - locations[-1])
                      - chunksizes(len(divisions) - 1)
                  )
              if enforce_exact:
                  divs_remain -= 1
              i = pos + max(1, chunksizes(len(divisions)) - drift)
              divisions.append(div)
              locations.append(pos)
              ind = None
  
      # The final element of divisions/locations
      # will always be the same
      divisions.append(seq[-1])
      locations.append(len(seq))
  
      return divisions, locations
  
imports: from __future__ import annotations
  from collections.abc import Iterable
  from functools import partial
  from math import ceil
  from operator import getitem
  from threading import Lock
  from typing import TYPE_CHECKING, Literal, overload
  import numpy
  import pandas
  import dask.array
  from dask.base import is_dask_collection, tokenize
  from dask.blockwise import BlockwiseDepDict, blockwise
  from dask.dataframe._compat import is_any_real_numeric_dtype
  from dask.dataframe.backends import dataframe_creation_dispatch
  from dask.dataframe.core import DataFrame, Index, Series, _concat, _emulate, _Frame, apply_and_enforce, has_parallel_type, new_dd_object
  from dask.dataframe.dispatch import meta_lib_from_array
  from dask.dataframe.io.utils import DataFrameIOFunction
  from dask.dataframe.utils import check_meta, insert_meta_param_description, is_series_like, make_meta
  from dask.delayed import Delayed, delayed
  from dask.highlevelgraph import HighLevelGraph
  from dask.layers import DataFrameIOLayer
  from dask.utils import M, funcname, is_arraylike
label_desc: Use image node_id 14 for calling a global function with example usage: sorted_division_locations(seq, npartitions, chunksize) and returns: divisions,  locations, unknown