code: def clean_names(
      df: DataFrame,
      case_type: str = "lower",
      remove_special: bool = False,
      strip_underscores: str = None,
  ) -> DataFrame:
      """Clean column names for pyspark dataframe.
  
      Takes all column names, converts them to lowercase, then replaces all
      spaces with underscores.
  
      This method does not mutate the original DataFrame.
  
      Examples:
          >>> from pyspark.sql import DataFrame
          >>> import janitor.spark
          >>> df = DataFrame(...).clean_names()  # doctest: +SKIP
  
          Example of transformation:
  
          ```
          Columns before: First Name, Last Name, Employee Status, Subject
          Columns after: first_name, last_name, employee_status, subject
          ```
  
      Args:
          df: Spark DataFrame object.
          strip_underscores: Removes the outer underscores from all
              column names. Default None keeps outer underscores. Values can be
              either 'left', 'right' or 'both' or the respective shorthand 'l',
              'r' and True.
          case_type: Whether to make columns lower or uppercase.
              Current case may be preserved with 'preserve',
              while snake case conversion (from CamelCase or camelCase only)
              can be turned on using "snake".
              Default 'lower' makes all characters lowercase.
          remove_special: Remove special characters from columns.
              Only letters, numbers and underscores are preserved.
  
      Returns:
          A Spark DataFrame.
      """
  
      cols = df.columns
  
      cols = [_change_case(col, case_type) for col in cols]
  
      cols = [_normalize_1(col) for col in cols]
  
      if remove_special:
          cols = [_remove_special(col) for col in cols]
  
      cols = [re.sub("_+", "_", col) for col in cols]  # noqa: PD005
  
      cols = [
          _strip_underscores_func(col, strip_underscores)
          for col in cols
      ]
  
      cols = [
          f"`{col}` AS `{new_col}`"
          for col, new_col in zip(df.columns, cols)
      ]
  
      return df.selectExpr(*cols)
  
imports: import re
  from typing import Union
  from janitor import utils
  from janitor.functions.clean_names import _change_case, _normalize_1, _remove_special, _strip_underscores_func
  from .None import backend
label_desc: Use image node_id 1 for calling a global function with example usage: clean_names(df, case_type, remove_special, strip_underscores) and returns: df