code: def from_pandas(
      data: pd.DataFrame | pd.Series,
      npartitions: int | None = None,
      chunksize: int | None = None,
      sort: bool = True,
      name: str | None = None,
  ) -> DataFrame | Series:
      """
      Construct a Dask DataFrame from a Pandas DataFrame
  
      This splits an in-memory Pandas dataframe into several parts and constructs
      a dask.dataframe from those parts on which Dask.dataframe can operate in
      parallel.  By default, the input dataframe will be sorted by the index to
      produce cleanly-divided partitions (with known divisions).  To preserve the
      input ordering, make sure the input index is monotonically-increasing. The
      ``sort=False`` option will also avoid reordering, but will not result in
      known divisions.
  
      Note that, despite parallelism, Dask.dataframe may not always be faster
      than Pandas.  We recommend that you stay with Pandas for as long as
      possible before switching to Dask.dataframe.
  
      Parameters
      ----------
      data : pandas.DataFrame or pandas.Series
          The DataFrame/Series with which to construct a Dask DataFrame/Series
      npartitions : int, optional
          The number of partitions of the index to create. Note that if there
          are duplicate values or insufficient elements in ``data.index``, the
          output may have fewer partitions than requested.
      chunksize : int, optional
          The desired number of rows per index partition to use. Note that
          depending on the size and index of the dataframe, actual partition
          sizes may vary.
      sort: bool
          Sort the input by index first to obtain cleanly divided partitions
          (with known divisions).  If False, the input will not be sorted, and
          all divisions will be set to None. Default is True.
      name: string, optional
          An optional keyname for the dataframe.  Defaults to hashing the input
  
      Returns
      -------
      dask.DataFrame or dask.Series
          A dask DataFrame/Series partitioned along the index
  
      Examples
      --------
      >>> from dask.dataframe import from_pandas
      >>> df = pd.DataFrame(dict(a=list('aabbcc'), b=list(range(6))),
      ...                   index=pd.date_range(start='20100101', periods=6))
      >>> ddf = from_pandas(df, npartitions=3)
      >>> ddf.divisions  # doctest: +NORMALIZE_WHITESPACE
      (Timestamp('2010-01-01 00:00:00', freq='D'),
       Timestamp('2010-01-03 00:00:00', freq='D'),
       Timestamp('2010-01-05 00:00:00', freq='D'),
       Timestamp('2010-01-06 00:00:00', freq='D'))
      >>> ddf = from_pandas(df.a, npartitions=3)  # Works with Series too!
      >>> ddf.divisions  # doctest: +NORMALIZE_WHITESPACE
      (Timestamp('2010-01-01 00:00:00', freq='D'),
       Timestamp('2010-01-03 00:00:00', freq='D'),
       Timestamp('2010-01-05 00:00:00', freq='D'),
       Timestamp('2010-01-06 00:00:00', freq='D'))
  
      Raises
      ------
      TypeError
          If something other than a ``pandas.DataFrame`` or ``pandas.Series`` is
          passed in.
  
      See Also
      --------
      from_array : Construct a dask.DataFrame from an array that has record dtype
      read_csv : Construct a dask.DataFrame from a CSV file
      """
      if isinstance(getattr(data, "index", None), pd.MultiIndex):
          raise NotImplementedError(
              "Dask does not support MultiIndex Dataframes."
          )
  
      if not has_parallel_type(data):
          raise TypeError("Input must be a pandas DataFrame or Series.")
  
      if (npartitions is None) == (chunksize is None):
          raise ValueError(
              "Exactly one of npartitions and chunksize must be specified."
          )
  
      nrows = len(data)
  
      if chunksize is None:
          if not isinstance(npartitions, int):
              raise TypeError(
                  "Please provide npartitions as an int, or possibly as None if you specify chunksize."
              )
      elif not isinstance(chunksize, int):
          raise TypeError(
              "Please provide chunksize as an int, or possibly as None if you specify npartitions."
          )
  
      name = name or (
          "from_pandas-" + tokenize(data, chunksize, npartitions)
      )
  
      if not nrows:
          return new_dd_object(
              {(name, 0): data}, name, data, [None, None]
          )
  
      if data.index.isna().any() and not is_any_real_numeric_dtype(
          data.index
      ):
          raise NotImplementedError(
              "Index in passed data is non-numeric and contains nulls, which Dask does not entirely support.\n"
              "Consider passing `data.loc[~data.isna()]` instead."
          )
  
      if sort:
          if not data.index.is_monotonic_increasing:
              data = data.sort_index(ascending=True)
          else:
              # sort_index copies as well
              data = data.copy()
          divisions, locations = sorted_division_locations(
              data.index,
              npartitions=npartitions,
              chunksize=chunksize,
          )
      else:
          data = data.copy()
          if chunksize is None:
              assert isinstance(npartitions, int)
              chunksize = int(ceil(nrows / npartitions))
          locations = list(range(0, nrows, chunksize)) + [len(data)]
          divisions = [None] * len(locations)
  
      dsk = {
          (name, i): data.iloc[start:stop]
          for i, (start, stop) in enumerate(
              zip(locations[:-1], locations[1:])
          )
      }
      return new_dd_object(dsk, name, data, divisions)
  
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 5 for calling a global function with example usage: from_pandas(data, npartitions, chunksize, sort, name) and returns: new_dd_object, new_dd_object