code: def pivot_table(
      data,
      values=None,
      index=None,
      columns=None,
      aggfunc="mean",
      fill_value=None,
      margins=False,
      dropna=None,
      margins_name="All",
      observed=False,
      sort=True,
  ):
      """
      Create a spreadsheet-style pivot table as a DataFrame.
  
      Parameters
      ----------
      data : DataFrame
      values : column name or list of column names to aggregate, optional
      index : list of column names
              Values to group by in the rows.
      columns : list of column names
              Values to group by in the columns.
      aggfunc : str or dict, default "mean"
              If dict is passed, the key is column to aggregate
              and value is function name.
      fill_value : scalar, default None
          Value to replace missing values with
          (in the resulting pivot table, after aggregation).
      margins : Not supported
      dropna : Not supported
      margins_name : Not supported
      observed : Not supported
      sort : Not supported
  
      Returns
      -------
      DataFrame
          An Excel style pivot table.
      """
      if margins is not False:
          raise NotImplementedError("margins is not supported yet")
  
      if margins_name != "All":
          raise NotImplementedError("margins_name is not supported yet")
  
      if dropna is not None:
          raise NotImplementedError("dropna is not supported yet")
  
      if observed is not False:
          raise NotImplementedError("observed is not supported yet")
  
      if sort is not True:
          raise NotImplementedError("sort is not supported yet")
  
      keys = index + columns
  
      values_passed = values is not None
      if values_passed:
          if pd.api.types.is_list_like(values):
              values_multi = True
              values = list(values)
          else:
              values_multi = False
              values = [values]
  
          for i in values:
              if i not in data:
                  raise KeyError(i)
  
          to_filter = []
          for x in keys + values:
              if isinstance(x, cudf.Grouper):
                  x = x.key
              try:
                  if x in data:
                      to_filter.append(x)
              except TypeError:
                  pass
          if len(to_filter) < len(data._column_names):
              data = data[to_filter]
  
      else:
          values = data.columns
          for key in keys:
              try:
                  values = values.drop(key)
              except (TypeError, ValueError, KeyError):
                  pass
          values = list(values)
  
      grouped = data.groupby(keys)
      agged = grouped.agg(aggfunc)
  
      table = agged
  
      if table.index.nlevels > 1 and index:
          # If index_names are integers, determine whether the integers refer
          # to the level position or name.
          index_names = agged.index.names[: len(index)]
          to_unstack = []
          for i in range(len(index), len(keys)):
              name = agged.index.names[i]
              if name is None or name in index_names:
                  to_unstack.append(i)
              else:
                  to_unstack.append(name)
          table = agged.unstack(to_unstack)
  
      if fill_value is not None:
          table = table.fillna(fill_value)
  
      # discard the top level
      if values_passed and not values_multi and table._data.multiindex:
          column_names = table._data.level_names[1:]
          table_columns = tuple(
              map(lambda column: column[1:], table._data.names)
          )
          table.columns = cudf.MultiIndex.from_tuples(
              tuples=table_columns, names=column_names
          )
  
      if len(index) == 0 and len(columns) > 0:
          table = table.T
  
      return table
  
imports: import itertools
  import warnings
  from collections import abc
  from typing import Dict, Optional
  import cupy
  import numpy
  import pandas
  import cudf
  from cudf._lib.transform import one_hot_encode
  from cudf._lib.types import size_type_dtype
  from cudf._typing import Dtype
  from cudf.api.extensions import no_default
  from cudf.core.column import ColumnBase, as_column, column_empty_like
  from cudf.core.column.categorical import CategoricalColumn
  from cudf.utils.dtypes import min_unsigned_type
label_desc: Use image node_id 16 for calling a global function with example usage: pivot_table(data, values, index, columns, aggfunc, fill_value, margins, dropna, margins_name, observed, sort) and returns: table