code: def _computations_pivot_wider(
      df: pd.DataFrame,
      index: Optional[Union[list, str]] = None,
      names_from: Optional[Union[list, str]] = None,
      values_from: Optional[Union[list, str]] = None,
      flatten_levels: Optional[bool] = True,
      names_sep: str = "_",
      names_glue: str = None,
      reset_index: bool = True,
      names_expand: bool = False,
      index_expand: bool = False,
  ) -> pd.DataFrame:
      """
      This is the main workhorse of the `pivot_wider` function.
  
      It is a wrapper around `pd.pivot`.
      The output for multiple `names_from` and/or `values_from`
      can be controlled with `names_glue` and/or `names_sep`.
  
      A dataframe pivoted from long to wide form is returned.
      """
  
      (
          df,
          index,
          names_from,
          values_from,
          flatten_levels,
          names_sep,
          names_glue,
          reset_index,
          names_expand,
          index_expand,
      ) = _data_checks_pivot_wider(
          df,
          index,
          names_from,
          values_from,
          flatten_levels,
          names_sep,
          names_glue,
          reset_index,
          names_expand,
          index_expand,
      )
  
      out = df.pivot(  # noqa: PD010
          index=index, columns=names_from, values=values_from
      )
  
      indexer = out.index
      if index_expand and index:
          any_categoricals = (
              indexer.get_level_values(name) for name in index
          )
          any_categoricals = any(
              map(is_categorical_dtype, any_categoricals)
          )
          if any_categoricals:
              indexer = _expand(indexer, retain_categories=True)
              out = out.reindex(index=indexer)
  
      indexer = out.columns
      if names_expand:
          any_categoricals = (
              indexer.get_level_values(name) for name in names_from
          )
          any_categoricals = any(
              map(is_categorical_dtype, any_categoricals)
          )
          if any_categoricals:
              retain_categories = True
              if flatten_levels & (
                  (names_glue is not None)
                  | isinstance(indexer, pd.MultiIndex)
                  | ((index is not None) & reset_index)
              ):
                  retain_categories = False
              indexer = _expand(
                  indexer, retain_categories=retain_categories
              )
              out = out.reindex(columns=indexer)
  
      indexer = None
      if any((out.empty, not flatten_levels)):
          return out
  
      if isinstance(out.columns, pd.MultiIndex) and names_glue:
          new_columns = out.columns
          if ("_value" in names_from) and (None in new_columns.names):
              warnings.warn(
                  "For names_glue, _value is used as a placeholder "
                  "for the values_from section. "
                  "However, there is a '_value' in names_from; "
                  "this might result in incorrect output. "
                  "If possible, kindly change the column label "
                  "from '_value' to another name, "
                  "to avoid erroneous results."
              )
          try:
              # there'll only be one None
              names_from = [
                  "_value" if ent is None else ent
                  for ent in new_columns.names
              ]
              new_columns = [
                  names_glue.format_map(dict(zip(names_from, entry)))
                  for entry in new_columns
              ]
          except KeyError as error:
              raise KeyError(
                  f"{error} is not a column label in names_from."
              ) from error
  
          out.columns = new_columns
      elif names_glue:
          try:
              new_columns = [
                  names_glue.format_map({names_from[0]: entry})
                  for entry in out.columns
              ]
          except KeyError as error:
              raise KeyError(
                  f"{error} is not a column label in names_from."
              ) from error
          out.columns = new_columns
      else:
          names_sep = "_" if names_sep is None else names_sep
          out = out.collapse_levels(sep=names_sep)
  
      if index and reset_index:
          out = out.reset_index()
  
      if out.columns.names:
          out.columns.names = [None]
  
      return out
  
imports: import re
  import warnings
  from collections import defaultdict
  from itertools import chain, zip_longest
  from typing import Callable, Optional, Pattern, Union
  import numpy
  import pandas
  import pandas_flavor
  from pandas.api.types import is_categorical_dtype, is_extension_array_dtype, is_list_like
  from pandas.core.dtypes.concat import concat_compat
  from janitor.functions.utils import _computations_expand_grid, get_index_labels
  from janitor.utils import check, refactored_function
label_desc: Use image node_id 13 for calling a global function with example usage: _computations_pivot_wider(df, index, names_from, values_from, flatten_levels, names_sep, names_glue, reset_index, names_expand, index_expand) and returns: out, out