code: def _computations_pivot_longer(
      df: pd.DataFrame,
      index: Union[list, None],
      column_names: Union[list, None],
      names_to: Union[list, None],
      values_to: Union[list, str, None],
      names_sep: Union[str, Pattern],
      names_pattern: Union[list, tuple, str, Pattern],
      names_transform: Union[str, Callable, dict, None],
      dropna: bool,
      sort_by_appearance: bool,
      ignore_index: bool,
  ) -> pd.DataFrame:
      """
      This is where the final dataframe in long form is created.
      """
      # the core idea for the combination/reshape
      # is that the index will be tiled, while the rest will be repeated
      # where necessary ------->
      # if index is [1,2,3] then tiling makes it [1,2,3,1,2,3,...]
      # for column names, if it is [1,2,3], then repeats [1,1,1,2,2,2,3,3,3]
      # dump down into arrays, and build a new dataframe, with copy = False
      # since we already have made a copy of the original df
  
      if not column_names:
          return df
  
      if index:
          index = {name: df[name]._values for name in index}
  
      if len(column_names) != len(set(column_names)):
          column_names = pd.unique(column_names)
  
      # this is the reason why there is no explicit copy (df.copy())
      # at the very beginning for `pivot_longer`,
      # because `.loc` makes a copy of the dataframe
      out = df.loc[:, column_names]
  
      if all((names_pattern is None, names_sep is None)):
          return _base_melt(
              df=out,
              index=index,
              values_to=values_to,
              names_transform=names_transform,
              dropna=dropna,
              sort_by_appearance=sort_by_appearance,
              ignore_index=ignore_index,
          )
  
      if names_sep is not None:
          return _pivot_longer_names_sep(
              df=out,
              index=index,
              names_to=names_to,
              names_sep=names_sep,
              names_transform=names_transform,
              values_to=values_to,
              dropna=dropna,
              sort_by_appearance=sort_by_appearance,
              ignore_index=ignore_index,
          )
  
      if isinstance(names_pattern, (str, Pattern)):
          return _pivot_longer_names_pattern_str(
              df=out,
              index=index,
              names_to=names_to,
              names_pattern=names_pattern,
              names_transform=names_transform,
              values_to=values_to,
              dropna=dropna,
              sort_by_appearance=sort_by_appearance,
              ignore_index=ignore_index,
          )
  
      return _pivot_longer_names_pattern_sequence(
          df=out,
          index=index,
          names_to=names_to,
          names_pattern=names_pattern,
          names_transform=names_transform,
          dropna=dropna,
          sort_by_appearance=sort_by_appearance,
          values_to=values_to,
          ignore_index=ignore_index,
      )
  
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 3 for calling a global function with example usage: _computations_pivot_longer(df, index, column_names, names_to, values_to, names_sep, names_pattern, names_transform, dropna, sort_by_appearance, ignore_index) and returns: _pivot_longer_names_pattern_sequence, df, _base_melt, _pivot_longer_names_sep, _pivot_longer_names_pattern_str